Skip to content

Instantly share code, notes, and snippets.

@MaxLynam
Created November 14, 2014 04:04
Show Gist options
  • Select an option

  • Save MaxLynam/c59837b77d4609aea4fc to your computer and use it in GitHub Desktop.

Select an option

Save MaxLynam/c59837b77d4609aea4fc to your computer and use it in GitHub Desktop.
htaccess code sample . nice and efficient :)
# Force 'www.' on HTTP protocol
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTPS} !on
RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE]
# Force 'www.' on HTTPS protocol
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTPS} on
RewriteRule ^/?(.*) https://www.%{HTTP_HOST}/$1 [L,R,NE]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment