Created
September 21, 2017 15:57
-
-
Save apphp/6b6c3e3a9416c95f4b7e77df07445844 to your computer and use it in GitHub Desktop.
Force www./no-www. in .htaccess
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
# source: http://apphp.com/index.php?snippet=htaccess-www-or-no-www | |
# Force the www. | |
RewriteEngine On | |
RewriteCond %{HTTP_HOST} ^your-site.com [NC] | |
RewriteRule ^(.*)$ http://www.your-site.com/$1 [L,R=301] | |
# Remove the www. | |
RewriteEngine On | |
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC] | |
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment