Skip to content

Instantly share code, notes, and snippets.

@kathangeorg
Created May 10, 2012 07:40
Show Gist options
  • Save kathangeorg/2651727 to your computer and use it in GitHub Desktop.
Save kathangeorg/2651727 to your computer and use it in GitHub Desktop.
.htaccess reditect non www to www
#non www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#www to non www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
#http://dense13.com/blog/2008/02/27/redirecting-non-www-to-www-with-htaccess/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment