Created
June 29, 2016 12:35
-
-
Save anjan011/8f7440922ded8621353d9327d2fdffee to your computer and use it in GitHub Desktop.
htaccess - redirect to https and www domain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteCond %{HTTPS} off | |
# First rewrite to HTTPS: | |
# Don't put www. here. If it is already there it will be included, if not | |
# the subsequent rule will catch it. | |
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# Now, rewrite any request to the wrong domain to use www. | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule .* https://www.%{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