Created
January 10, 2017 19:36
-
-
Save orlov0562/e6e869557737f524a5a79e2084e42010 to your computer and use it in GitHub Desktop.
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
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
# if browser supports SNI set SERVER variable | |
SetEnv SSL_TLS_SNI %{SSL:SSL_TLS_SNI} | |
# if it's browser that supports SNI then redirect to https | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP_USER_AGENT} !MSIE\s[1-8]\. [NC] | |
RewriteCond %{HTTP_USER_AGENT} !Windows\sNT\s5\. [NC] | |
RewriteCond %{HTTP_USER_AGENT} !Opera/[1-3]\. [NC] | |
RewriteCond %{HTTP_USER_AGENT} !Safari/[1-4]\. [NC] | |
RewriteCond %{HTTP_USER_AGENT} !Navigator/ [NC] | |
RewriteCond %{HTTP_USER_AGENT} !Android.*(Mobile)?\s[0-3]\. [NC] | |
RewriteCond %{HTTP_USER_AGENT} !^(.*.symbian.*) [NC] | |
RewriteCond %{HTTP_USER_AGENT} !^(.*.blackberry.*) [NC] | |
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# if path doesn't contains www append it for both http and https | |
RewriteCond %{HTTPS} on | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment