You are currently viewing How to force SSL with .htaccess

How to force SSL with .htaccess

How to force SSL with .htaccess
You can force an HTTPS connection on your website by adding these rules in your website’s .htaccess file:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]

If your website is in a subfolder, use this code instead:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://yourdomain.com/folder/$1 [R=301,L]

Where yourdomain.com is your actual domain name and folder should be replaced with the name of the subfolder where your site is situated.

You can edit the .htaccess file either via FTP, or using with the File Manager availalbe in cPanel.

Jobair Alam Bipul

I'm Jobair Alam, a cPanel Certified WHM/cPanel server administrator and web hosting expert with over 10 years of experience in the industry.

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

HostArmada - Affordable Cloud SSD Web Hosting