Created
July 7, 2014 15:09
-
-
Save Wind4/204dc7c0dacd4eb7592b 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
RewriteEngine On | |
RewriteBase / | |
### Force WWW ### | |
RewriteCond %{HTTP_HOST} ^example\.com | |
RewriteRule (.*) http://www.example.com/$1 [R=301,L] | |
## Force SSL ### | |
RewriteCond %{SERVER_PORT} 80 | |
RewriteRule ^(.*)$ https://example.com/$1 [R,L] | |
## Block IP's ### | |
Order Deny,Allow | |
Deny from 256.251.0.139 | |
Deny from 199.127.0.259 | |
## Forece Non-www | |
RewriteCond %{HTTP_HOST} ^www\. [NC] | |
RewriteRule ^(.*)$ %{HTTP_HOST}$1 [C] | |
RewriteRule ^www\.(.*)$ http://$1 [L,R=301] | |
######################################### | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] | |
RewriteCond %{HTTPS} on | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] | |
######################################### | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] | |
RewriteCond %{HTTPS} on | |
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment