Created
July 15, 2019 12:59
-
-
Save townivan/542489a55d1f13480e34fc4c8d12cede to your computer and use it in GitHub Desktop.
htaccess which redirects http://domain, https://domain, http://www.domain to https://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
# if host contains www - skip redirect to www | |
RewriteCond %{HTTP_HOST} ^www\. [NC] | |
RewriteRule .? - [S=1] | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# redirect all 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