Cpanel

Redirecting HTTP to HTTPS Using .htaccess File

Redirect-HTTP-to-HTTPS

Redirecting htt to https using .htaccess file, but make sure your site install SSL certificate, you can also see How to install SSL Certificate

Editing .htaccess in cPanel

  1. Login to cPanel
  2. Files > File Manager > Document Root for:
  3. Now select the domain name you want to access
  4. Check “Show Hidden Files (dotfiles)” See below Image
  1. After a new tab or window opens, look for the .htaccess file.
  2. Right click on the .htaccess file and click on “Code Edit” on the menu.
  3. A dialogue box may pop up asking about encoding. Click the “Edit” button to continue.
  4. Edit the file
RewriteEngine On

### WWW & HTTPS

# ensure www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ensure https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  1. “Save Changes”.
  2. Test your website to make sure it is done correctly.
Team sharabindu
Sharabindu Editorial Team

The editorial team at Sharabindu consists of a group of highly trained WordPress professionals who strive to deliver nothing but excellence.

Related Posts

How to Get Free SSL Using Cloudflare

SSL is secure connections from a web server to a browser, When installed on a web server, it activates the

Read More »

How to fix Notepad++ NULL values after the crash

You are working on Notepad++, suddenly the Electricity went away or crashed for some other reason, after opening the file,

Read More »