Skip to content

Instantly share code, notes, and snippets.

@lfbittencourt
Last active January 12, 2019 13:39
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 lfbittencourt/d24dfd9f31e6b30f279e20458b593f72 to your computer and use it in GitHub Desktop.
Save lfbittencourt/d24dfd9f31e6b30f279e20458b593f72 to your computer and use it in GitHub Desktop.
Force non-www SSL version of a site
<IfModule mod_rewrite.c>
RewriteEngine On
# Force non-www
RewriteCond %{HTTP_HOST} ^www\.foo\.com$ [NC]
RewriteRule ^(.*)$ https://foo.com/$1 [L,R=301]
# Force SSL
RewriteCond %{HTTP_HOST} ^foo\.com$ [NC]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment