Skip to content

Instantly share code, notes, and snippets.

@Kaapiii
Created February 16, 2013 22:15
Show Gist options
  • Save Kaapiii/4968970 to your computer and use it in GitHub Desktop.
Save Kaapiii/4968970 to your computer and use it in GitHub Desktop.
Redirecting non-www to www and vice versa
# Redirecting non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# Redirecting www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment