Last active
December 7, 2017 16:52
-
-
Save dejurin/f1d70e183985089fd3c36c5dd9c88587 to your computer and use it in GitHub Desktop.
htaccess: redirect HTTP to HTTPS with without WWW
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
// without wwww | |
RewriteCond %{HTTPS} off [OR] | |
RewriteCond %{HTTP_HOST} ^www\. [NC] | |
RewriteRule ^ https://{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301] | |
// with www | |
RewriteCond %{HTTPS} off | |
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
// read more https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/ | |
// bitrix | |
RewriteEngine On | |
RewriteCond %{SERVER_PORT} !^443$ | |
RewriteRule .* https://example.com/$1 [R,L] | |
// all | |
RewriteEngine On | |
RewriteCond %{SERVER_PORT} !^443$ | |
RewriteRule .* https://example.com/$1 [R=301,L] | |
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] | |
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment