Created
January 20, 2016 23:29
-
-
Save bransinanderson/0df0ef6e6428725a483a 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
# Option 1: | |
# Rewrite "www.example.com -> example.com" | |
<IfModule mod_rewrite.c> | |
# If not an SSL request WITHOUT WWW | |
RewriteCond %{HTTPS} !=on | |
RewriteCond %{HTTP_HOST} !^www\..+$ [NC] | |
RewriteCond %{HTTP_HOST} !^(local\..+|staging\..+|.+dev)$ [NC] | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
# If not an SSL request WITH WWW | |
RewriteCond %{HTTPS} !=on | |
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] | |
RewriteCond %{HTTP_HOST} !^(local\..+|staging\..+|.+dev)$ [NC] | |
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L] | |
# If SSL request WITH WWW | |
RewriteCond %{HTTPS} on | |
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] | |
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment