Created
September 5, 2013 17:50
-
-
Save ziadoz/6453657 to your computer and use it in GitHub Desktop.
Apache rewrite non-www to www and vice versa.
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 / | |
# Rewrite: non-www to www | |
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L] | |
# Rewrite: www to non-www | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
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