Redirect website to HTTPS in cPanel/Linux

If you have a secure socket layer certificate (SSL) on your website, you can automatically redirect visitors to the secured (HTTPS) version of your site for a secure connection.

 
Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 
If you have an existing .htaccess file:
 
1.  Do not duplicate RewriteEngine On.
2.  Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already existing RewriteEngine On.

This will automatically redirect your bare domain to the secure HTTPS version.

Note: Custom site code can cause issues with the above method. If you are unable to follow above steps then we recommend contacting a website developer (outside of us) to assist.


Was this article helpful?

mood_bad Dislike 1
mood Like 0
visibility Views: 14615