How do I re-direct non-https traffic to the https version of the website?

With the latest cPanel version, there is a 'Force HTTPS Redirect' option in the 'Domains' area.

Simply click on 'Domains' in the section as show below:

cPanel - Domains


You can then click on 'Force HTTPS Redirect' in the next section as shown below:

Force HTTPS Redirect

If you prefer to direct traffic to HTTPS in other ways then please refer to the options below which will require you to edit your .htaccess file:

To re-direct a single site from http:// to https:// or https://www you would add the following code to an .htaccess file in the document root for the website (make sure to edit the entry for your specific domain):

Option 1 Redirects all http:// requests to the same website page, but with https://

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule .* https://example.com%{REQUEST_URI} [R=301,L]
</IfModule>

Option 2 Redirects all http:// requests to the same website page, but with https://www.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule .* https://www.example.com%{REQUEST_URI} [R=301,L]
</IfModule>

Was this answer helpful?

 Print this Article

Also Read

How to create a user-friendly URL using .htaccess?

If your website is using a long URL like example.com/files/folder/sitemap.html, you can change it...

Modifying existing .htaccess files

To modify/add directives to the .htaccess file in your public_html directory using "File...

How to redirect a page to another page or website using .htaccess?

If a page on your website no longer exists and you want to redirect it to your new page or...

Redirection using .htaccess

Most websites are constantly changing "works in progress" and as one updates, rearranges and...

Preventing bandwidth theft using .htaccess

While all HostRocket plans include plenty of bandwidth (transfer) nobody ever has enough...