Redirect Website from HTTP to HTTPS (.htaccess)

If you do not have a .htaccess file, create a .htaccess file in the public_html folder or in the root folder of the site.
Write the following code to the file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If the .htaccess file already exists
Do not duplicate RewriteEngine On.
Ensure that lines starting with RewriteCond and RewriteRule immediately follow RewriteEngine On.

  • http, https, redirect
  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

How to change PHP version and INI settings in cPanel hosting

MultiPHP for cPanel Skip to end of metadata   Go to start of metadata   With cPanel's...

How to upload your websites to Cpanel hosting

There are several ways to upload a site – we will provide you with the most common ones: 1....

Installing third-party SSL Certificate on cPanel account

Our cPanel accounts support SSL certificates from us, as well as third-party vendors. SSL...

How to unlock IP address in Server Firewall

We are proud of our secure servers. And if your IP address was blocked by mistake, you can easily...

Creating a database in cPanel (MySQL Database Wizard)

Log into your cPanel. Click the MySQL Database Wizard under the Databases heading. Next to...