Skip to content

Instantly share code, notes, and snippets.

@drakemccabe
Created May 3, 2016 17:11
Show Gist options
  • Save drakemccabe/0b01ae68ad535e1d544cc157f0ff0b7a to your computer and use it in GitHub Desktop.
Save drakemccabe/0b01ae68ad535e1d544cc157f0ff0b7a to your computer and use it in GitHub Desktop.
Rewrite urls to WWW without changing request's original protocol
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^<HOST>.com$ [NC]
RewriteRule ^(.*)$ http://www.<HOST>.com/$1 [L,R=301]
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^<HOST>.com$ [NC]
RewriteRule ^(.*)$ https://www.<HOST>.com/$1 [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment