Skip to content

Instantly share code, notes, and snippets.

@oreales
Last active August 29, 2015 14:01
Show Gist options
  • Save oreales/3b31c6a872de47a7d9b9 to your computer and use it in GitHub Desktop.
Save oreales/3b31c6a872de47a7d9b9 to your computer and use it in GitHub Desktop.
.htaccess rewrite a www y https
############################################
## rewrites to https y www
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, 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