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.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to log into cPanel

If you recently purchased a new account with Hostmight.Com, you should type the following...

I forgot my password and need a reset

CPANEL /WHM Check your welcome email for the correct user name and password. If that password is...

how can i create subdomain on cpanel?

In order to create a new subdomain in your Cpanel hosting plan you will first need to log into...

How do I create and remove an Addon Domain?

Login to your cPanel and click Addon Domains, under Domains. There are three fields cPanel asks...

How Can I See My Total Disk Space and Bandwidth Available on My Reseller Account?

How Can I See My Total Disk Space and Bandwidth Available on My Reseller Account? If you would...