Skip to content

Instantly share code, notes, and snippets.

@cameronjonesweb
Last active January 15, 2017 05:58
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 cameronjonesweb/e2146132230be6aa3f54dd0d935a417e to your computer and use it in GitHub Desktop.
Save cameronjonesweb/e2146132230be6aa3f54dd0d935a417e to your computer and use it in GitHub Desktop.
www or non-www redirects with .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment