Last active
August 29, 2015 14:11
-
-
Save jacks0n/c39d60b47a71d8f36d0a to your computer and use it in GitHub Desktop.
Force the www or non-www canonical domain (example.com => www.example.com or www.example.com => example.com). Includes re-directing files/assets.
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
# Force the canonical www-subdomain | |
# example.com => www.example.com | |
RewriteEngine On | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] | |
# Force the canonical root domain | |
# www.example.com => example.com | |
RewriteEngine On | |
RewriteCond %{HTTP_HOST} ^www\. | |
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment