Skip to content

Instantly share code, notes, and snippets.

@refactorsaurusrex
Last active January 7, 2020 18:45
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 refactorsaurusrex/6b7d86cb2b7374e3a8b7b55517d1ecce to your computer and use it in GitHub Desktop.
Save refactorsaurusrex/6b7d86cb2b7374e3a8b7b55517d1ecce to your computer and use it in GitHub Desktop.
How to simultaneously 1) redirect http to https AND 2) remove 'www', if it exists, using an htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://example.com%{REQUEST_URI} [R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment