Skip to content

Instantly share code, notes, and snippets.

@jserrao
Created March 27, 2014 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jserrao/9810207 to your computer and use it in GitHub Desktop.
Save jserrao/9810207 to your computer and use it in GitHub Desktop.
Redirects: example.com to 'www' & 'www' to example.com
# example.com to 'www'
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# 'www' to example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment