Skip to content

Instantly share code, notes, and snippets.

@sigu
Last active April 20, 2018 08:47
Show Gist options
  • Save sigu/ebee18b78fd2978aaf2a7ece3aec5815 to your computer and use it in GitHub Desktop.
Save sigu/ebee18b78fd2978aaf2a7ece3aec5815 to your computer and use it in GitHub Desktop.
Redirect all non http to https versions of the webite in cpanel
#Comment | Uncomment ''RewriteEngine on'' below if it is not in your public_html .htaccess file
#You only need to have this once in the public_html .htaccess as it covers all other Rewrites
RewriteEngine on
#Comment | Force all URLs to https WITHOUT www
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
#Comment | Force all URLs to https WITH www
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment