Created
May 29, 2018 20:24
-
-
Save brentini/0cd4a55a339944724cfd60f8c07a94d4 to your computer and use it in GitHub Desktop.
Forcing SSL and WWW using .htaccess #htaccess #apache #ssl
This file contains hidden or 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
RewriteEngine on | |
# Force www: from http://stackoverflow.com/a/4958847/1078583 | |
RewriteCond %{HTTP_HOST} !^$ | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteCond %{HTTPS}s ^on(s)| | |
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
# Force SSL: From http://stackoverflow.com/q/24322035/ | |
RewriteCond %{HTTPS} off | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment