Skip to main content

Forcing a HTTPS redirect in cPanel - Knowledgebase / Security - Micron21 Helpdesk

Forcing a HTTPS redirect in cPanel

Authors list

Overview:

Avoid security warnings when accessing your site with an SSL certificate and forced HTTPS redirect.

Prerequisites:

Ensure you have a valid SSL installed on your cPanel services. If you do not have one, you can use cPanel's AutoSSL service by following this guide


Method

  1. Log into your cPanel hosting service.

  2. Navigate to the "Domains" tool.

  3. Toggle the “Force HTTPS Redirect” option to on for any domains with an SSL installed.

  4. This change should be immediate.  To test, clear your browser cache and open your website,  ensuring you specify HTTP://.  The URL will automatically be redirected to the HTTPS:// version of the URL.

Manual Method

If you have any issues with the above method, you can manually create the redirect by adding the following code to the top of your ".htaccess " file:

# START HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# END HTTPS

Editing your ".htaccess" file:

  1. Log into your cPanel hosting service.

  2. Navigate to the "File Manager" tool, which is under "Files".

  3. Navigate to the "public_html" folder or to the folder where your website is located.

  4. Locate your ".htaccess" file,  right-click on it, then click "Edit".

    1. By default, the ".htaccess" will be hidden - as it is a dot file. To reveal dot files in the File Manager, click "Settings" (top-right), then select “Show Hidden Files”, and then save this.

    2. If the file doesn’t exist, click the "+ File" button to the top-left of the page, then create one of the same name.

  5. Paste the above code at the top of the file on its own lines.


Helpful Unhelpful