How to do Https 301 redirect on cPanel?

Server

Permanent SEO-safe 301 redirect from HTTP to HTTPS, which is a method that I use a lot on Plesk panel but not on CPanel, prevents your users and SEO engines from establishing insecure connections by redirecting http links within the site to https by the server. Links are answered securely.

Add the following lines to the top of the .htaccess file of the site on the cPanel, sometimes it may not work on the bottom lines.

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

If you cannot see the htaccess file, tick show hidden files by pressing the settings button in the upper right corner of the file system.

Category Server
starting logo