Last active
January 11, 2017 17:13
-
-
Save lfbittencourt/763ef618e20aca5d0235e3b1d23a1238 to your computer and use it in GitHub Desktop.
.htaccess to force www or non-www version
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
# IMPORTANT: if there are another rules, put these ones right after "RewriteEngine on" | |
# Force non-www | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com [NC] | |
RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301] | |
# Force www | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC] | |
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment