Skip to content

Instantly share code, notes, and snippets.

@janus57
Last active September 23, 2018 15:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save janus57/613f60aa0699cf3ff4567ddc8172b8c0 to your computer and use it in GitHub Desktop.
www or none ? That is the question
# Rewrite engine => "Power ON"
RewriteEngine On
RewriteBase /
# Force non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Force www
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