Skip to content

Instantly share code, notes, and snippets.

@tylerflint
Created October 20, 2011 19:37
Show Gist options
  • Save tylerflint/1302094 to your computer and use it in GitHub Desktop.
Save tylerflint/1302094 to your computer and use it in GitHub Desktop.
apache redirect www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://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