Skip to content

Instantly share code, notes, and snippets.

@isaumya
Created October 10, 2016 11:27
Show Gist options
  • Save isaumya/b04fa381e8a79f8e3a559e6b69013e17 to your computer and use it in GitHub Desktop.
Save isaumya/b04fa381e8a79f8e3a559e6b69013e17 to your computer and use it in GitHub Desktop.
Code for doing 301 HTTPS redirection for any site using .htaccess
<IfModule mod_headers.c>
RewriteEngine on
RewriteBase /
RewriteCond %{http_host} !^www.example.com$ [nc,OR]
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment