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 %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

The .htaccess file needs to be located inside the site's document root folder. If your website is in a subfolder, then the .htaccess should be placed in the corresponding sub folder.
You can create or edit the .htaccess file either via FTP, or using it with the File Manager available in cPanel.

  • SSL Certificate, cPanel, SSL, htaccess
  • 45 Users Found This Useful
Was this answer helpful?

Related Articles

My PHP scripts produce Internal Server Errors (500 error)

Some of our servers run PHP scripts as your own user instead of the global web server user. PHP...

PHP Sample Form mailer

Question: Where can I get sample php-form-mail script (form to email) script ? <!-- /*...

How can I view my client's web site before the domain propagates?

Since the client's account is sharing an IP with other sites, you have to use the ~account method...

How to use Entropy Search

This script enables a nice, quick search engine that can help your visitors find information that...

How to check server status?

http://www.trafficpullz.com/serverstatus/This will indicate to you whether a server or service,...