Skip to content

Instantly share code, notes, and snippets.

@abrahamvegh
Last active December 11, 2015 16:58
Show Gist options
  • Save abrahamvegh/4630846 to your computer and use it in GitHub Desktop.
Save abrahamvegh/4630846 to your computer and use it in GitHub Desktop.
Some 100% generic rewrite rules for enforcing desired URL and HTTPS modes.
RewriteEngine on
# Force No-WWW
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment