Skip to main content
Adde code analysis
Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

It sounds like you may have put the directives in the wrong place in your .htaccess file. The HTTP to HTTPS redirect needs to go near the top, before any other rewrites.

The nature of your URLs suggest you are using a front-controller type pattern and rewriting requests to a common script. However, the "homepage" does not need to be rewritten (since mod_dir will issue an internal subrequest for the directory index). If you place the mod_rewrite redirect after the front-controller then all but the homepage will be redirected.

UPDATE: From discussion in comments, there are no other directives in .htaccess and it would seem the website is driven with directives in the main server config (not accessible to the OP). Furthermore, it seems the .htaccess file (located in the /spintx subdirectory) is bypassed entirely for all requests, other than the homepage! Access to the server config is probably required in order to diagnose this further and implement an Apache HTTP to HTTPS redirect.

Implementing the HTTP to HTTPS redirect in the web application itself (Drupal 7) would perhaps be an alternative.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

These directives are generally OK for most servers. You don't really need the way<IfModule> wrapper, unless you are planning on copying these same directives to gomultiple servers where mod_rewrite might not be installed.

The RewriteRule pattern ^(.*)$ can be simplified to just ^ since the captured subpattern is not being used in the substitution (you are using the REQUEST_URI server variable instead).

It sounds like you may have put the directives in the wrong place in your .htaccess file. The HTTP to HTTPS redirect needs to go near the top, before any other rewrites.

The nature of your URLs suggest you are using a front-controller type pattern and rewriting requests to a common script. However, the "homepage" does not need to be rewritten (since mod_dir will issue an internal subrequest for the directory index). If you place the mod_rewrite redirect after the front-controller then all but the homepage will be redirected.

UPDATE: From discussion in comments, there are no other directives in .htaccess and it would seem the website is driven with directives in the main server config (not accessible to the OP). Furthermore, it seems the .htaccess file (located in the /spintx subdirectory) is bypassed entirely for all requests, other than the homepage! Access to the server config is probably required in order to diagnose this further and implement an Apache HTTP to HTTPS redirect.

Implementing the HTTP to HTTPS redirect in the web application itself (Drupal 7) would perhaps be the way to go.

It sounds like you may have put the directives in the wrong place in your .htaccess file. The HTTP to HTTPS redirect needs to go near the top, before any other rewrites.

The nature of your URLs suggest you are using a front-controller type pattern and rewriting requests to a common script. However, the "homepage" does not need to be rewritten (since mod_dir will issue an internal subrequest for the directory index). If you place the mod_rewrite redirect after the front-controller then all but the homepage will be redirected.

UPDATE: From discussion in comments, there are no other directives in .htaccess and it would seem the website is driven with directives in the main server config (not accessible to the OP). Furthermore, it seems the .htaccess file (located in the /spintx subdirectory) is bypassed entirely for all requests, other than the homepage! Access to the server config is probably required in order to diagnose this further and implement an Apache HTTP to HTTPS redirect.

Implementing the HTTP to HTTPS redirect in the web application itself (Drupal 7) would be an alternative.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

These directives are generally OK for most servers. You don't really need the <IfModule> wrapper, unless you are planning on copying these same directives to multiple servers where mod_rewrite might not be installed.

The RewriteRule pattern ^(.*)$ can be simplified to just ^ since the captured subpattern is not being used in the substitution (you are using the REQUEST_URI server variable instead).

Update regarding the bypass of htaccess
Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

It sounds like you may have put the directives in the wrong place in your .htaccess file. The HTTP to HTTPS redirect needs to go near the top, before any other rewrites.

The nature of your URLs suggest you are using a front-controller type pattern and rewriting requests to a common script. However, the "homepage" does not need to be rewritten (since mod_dir will issue an internal subrequest for the directory index). If you place the mod_rewrite redirect after the front-controller then all but the homepage will be redirected.

UPDATE: From discussion in comments, there are no other directives in .htaccess and it would seem the website is driven with directives in the main server config (not accessible to the OP). Furthermore, it seems the .htaccess file (located in the /spintx subdirectory) is bypassed entirely for all requests, other than the homepage! Access to the server config is probably required in order to diagnose this further and implement an Apache HTTP to HTTPS redirect.

Implementing the HTTP to HTTPS redirect in the web application itself (Drupal 7) would perhaps be the way to go.

It sounds like you may have put the directives in the wrong place in your .htaccess file. The HTTP to HTTPS redirect needs to go near the top, before any other rewrites.

The nature of your URLs suggest you are using a front-controller type pattern and rewriting requests to a common script. However, the "homepage" does not need to be rewritten (since mod_dir will issue an internal subrequest for the directory index). If you place the mod_rewrite redirect after the front-controller then all but the homepage will be redirected.

It sounds like you may have put the directives in the wrong place in your .htaccess file. The HTTP to HTTPS redirect needs to go near the top, before any other rewrites.

The nature of your URLs suggest you are using a front-controller type pattern and rewriting requests to a common script. However, the "homepage" does not need to be rewritten (since mod_dir will issue an internal subrequest for the directory index). If you place the mod_rewrite redirect after the front-controller then all but the homepage will be redirected.

UPDATE: From discussion in comments, there are no other directives in .htaccess and it would seem the website is driven with directives in the main server config (not accessible to the OP). Furthermore, it seems the .htaccess file (located in the /spintx subdirectory) is bypassed entirely for all requests, other than the homepage! Access to the server config is probably required in order to diagnose this further and implement an Apache HTTP to HTTPS redirect.

Implementing the HTTP to HTTPS redirect in the web application itself (Drupal 7) would perhaps be the way to go.

Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

It sounds like you may have put the directives in the wrong place in your .htaccess file. The HTTP to HTTPS redirect needs to go near the top, before any other rewrites.

The nature of your URLs suggest you are using a front-controller type pattern and rewriting requests to a common script. However, the "homepage" does not need to be rewritten (since mod_dir will issue an internal subrequest for the directory index). If you place the mod_rewrite redirect after the front-controller then all but the homepage will be redirected.