5c15d976c05414422a31edd730ec1c55cffdefbd
By:
TIX

Redirect HTTP to HTTPS while including subdirectory/file

January 26, 2015 2.3k views

I am having trouble redirecting http://tix.kiwi/atd (or any folder/file) to https://tix.kiwi/atd. It appears to redirect to https://tix.kiwiatd instead - which of course isn't even a valid domain.

This is the code I'm using:

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^tix\.kiwi [NC]
 RewriteCond %{HTTPS} off
 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

I've restarted apache, and I've also tried to look at my apache error log, but nothing shows up when logging is enabled via:

 LogLevel alert rewrite:trace8
1 comment
  • Try this in your .htaccess instead:

    #force https 
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
1 Answer

This question was answered by @sierracircle:

Try this in your .htaccess instead:

#force https 
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

View the original comment

Have another answer? Share your knowledge.