Skip to main content

Redirecting your domain from http to https using .htaccess in cPanel

This article will show you how to use cPanel's file manager to force redirect all traffic coming over http:// to https:// via your .htaccess

Justin Catello avatar
Written by Justin Catello
Updated this week

Securing your website with HTTPS is essential for protecting user data, improving search engine rankings, and building trust with your visitors. One of the simplest ways to ensure all traffic is redirected to the secure version of your site is by updating your .htaccess file in cPanel. In this article, we’ll guide you through the steps to redirect your domain from HTTP to HTTPS using .htaccess, so your website always loads securely by default.

  1. Enter cPanel - If you don't know how, you can follow this guide.

  2. In cPanel, look for the File Manager option under the Files tab.

  3. In the File Manager, locate the .htaccess file inside the webroot of your website. Once you've found it, right-click on the file to open a menu. From the menu, select Edit to start editing your file. A pop-up will appear, click Edit to proceed.

  4. Within the file editor, Add the following code to the top of your .htaccess file. Once you are finished editing, click Save Changes in the top left corner.

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

  5. Please bear in mind, this is a generic way of doing it, so ANY domain within your account may also be affected by this depending on if the domain is located within a folder in the same location of the .htaccess file you modified. If this is the case and you only want to force HTTPS for a specific domain, its best to use the following:

    RewriteEngine On 
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]



    Congratulations! You've successfully redirected your domain from http to https using .htaccess in cPanel.

    If you have any questions, please don’t hesitate to contact our team via live chat.

    For technical inquiries, please feel free to reach our support team by emailing support@bigscoots.com from your registered email or by submitting a support ticket.

Did this answer your question?