Skip to content

Instantly share code, notes, and snippets.

@jserrao
Created Mar 27, 2014
Embed
What would you like to do?
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