Skip to content

Instantly share code, notes, and snippets.

@fernandiez
Last active June 1, 2016 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandiez/46a910407355cc16be8f2c4a65181dc5 to your computer and use it in GitHub Desktop.
Save fernandiez/46a910407355cc16be8f2c4a65181dc5 to your computer and use it in GitHub Desktop.
Redirection 301 .htaccess from HTTP to HTTPS (with www)
#Redirect 301 from HTTP to HTTPS
#First, rewrite any request to the correct domain (with www)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Then, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment