Skip to content

Instantly share code, notes, and snippets.

@stmoerman
Last active April 13, 2018 23:07
Show Gist options
  • Select an option

  • Save stmoerman/393f25dbe1f2553b1c0d1c288d36385e to your computer and use it in GitHub Desktop.

Select an option

Save stmoerman/393f25dbe1f2553b1c0d1c288d36385e to your computer and use it in GitHub Desktop.
Apache2 redirect non-www to www and http to https through .htaccess with mod_rewrite
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment