Redirect from HTTP to HTTPS using the Cpanel .htaccess file

September 05,2022

Redirect from HTTP to HTTPS using the Cpanel .htaccess file

On websites without SSL certificates, Chrome and Firefox have begun to display insecure warnings. Your website will appear unsecure to visitors if SSL is not installed. In order to ensure security, accessibility, or PCI compliance, an SSL-encrypted connection must be used. Making the switch from HTTP to HTTPS becomes crucial.

Edit the codes in the.htaccess file to make all of your web traffic use HTTPS. Here’s how to modify the.htaccess file before we discuss switching from HTTP to HTTPS. Skip to the Redirection stages if you are familiar.

Editing .htaccess File

The functionality of your website is directly impacted by the directives/instructions in the.htaccess file that inform the server what to do in specific circumstances. Ordinary directives in the.htaccess file:

  1. SVG IconRedirects
  2. SVG IconRewriting URLs

Editing .htaccess in cPanel File Manager

Note: Backup your website in case something goes wrong.

  • SVG IconLogin to cPanel
  • SVG IconFiles > File Manager > Document Root for:
  • SVG IconNow select the domain name you want to access
  • SVG IconCheck “Show Hidden Files (dotfiles)”
  • SVG IconClick “Go”
  • SVG IconAfter a new tab or window opens, look for the .htaccess file.
  • SVG IconRight click on the .htaccess file and click on “Code Edit” on the menu.
  • SVG IconA dialogue box may pop up asking about encoding. Click “Edit” button to continue.
  • SVG IconEdit the file
  • SVG Icon“Save Changes” when done.
  • SVG IconTest your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.
  • SVG IconOnce you are done, click “Close” to close the window.

Redirecting HTTP to HTTPS

Redirect All Web Traffic

Options -Indexes  
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you need still help then contact ChennaiHost – Best Web Hosting Company in Chennai Customer Support

Delivering the Best Customer Experience, Every Time!