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

On our DirectAdmin based servers there is an easy way to force a HTTPS redirect as well. To do so on one of our newer DirectAdmin servers you will want to select the "SSL Certificates" button and choose the proper domain from the dropdown menu in the upper right hand corner.

You will then want to select the checkbox labeled "Force SSL with https redirect" and click the save button to the right of this option. 

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>

  • 3 Utenti hanno trovato utile questa risposta
Hai trovato utile questa risposta?

Articoli Correlati

Creating custom error pages using .htaccess

One of the many things one can do to make their website a little more professional-looking is to...

Blocking users by IP address using .htaccess

Should you find that a few unruly visitors are causing you problems by posting unwanted messages...

Introduction to .htaccess

What is .htaccess? The Apache Web server utilizes a per-directory access and configuration...

Directory protection using .htaccess

One of the more common/popular uses of .htaccess is to password protect specific directories...

Setting a default index page using .htaccess

By default our servers will look for (in order) a file by the name of index.html, index.cgi,...