Skip to content

Instantly share code, notes, and snippets.

@cobbman
Last active May 11, 2017 00:31
Show Gist options
  • Save cobbman/3f4ce6014b7eba11546b9bd20727be90 to your computer and use it in GitHub Desktop.
Save cobbman/3f4ce6014b7eba11546b9bd20727be90 to your computer and use it in GitHub Desktop.
universal htaccess force www
### BEGIN FORCE WWW OR NON-WWW
<ifModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
#Force non-www:
#RewriteCond %{HTTP_HOST} www.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#Force www:
#RewriteCond %{HTTP_HOST} !^www. [NC]
#RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
</IfModule>
### END FORCE WWW OR NON-WWW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment