1. bluehost knowledge base

How To Force SSL On All Pages In .htaccess File

Forcing All Pages

You can force all of your pages to use HTTPS. To do this you will need to modify your .htaccess file.

Using the Code Editor in the File Manager, add these lines to the beginning of the .htaccess file.

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

Forcing Specific Pages

To setup SSL protection on specific pages, you must edit the .htaccess file specific to that domain. For more information, please see Accessing the File Manager.

Edit The .htaccess File

Once you have found the .htaccess file in the file manager these steps will explain how to edit the file to add protection.

  1. Right-click on the .htaccess file and select the Edit option.
  2. A pop-up message will appear, then click the Edit button.
  3. At the top of the file insert the following code:
        RewriteEngine On 
    	RewriteCond %{HTTPS} off 
    	RewriteCond %{REQUEST_URI} /[SSL Requested page]/ 
    	RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  4. Click the Save Changes button towards the top right corner of your screen.
  5. Check your website to ensure it is functioning as expected.
If that doesn't work, you can try using this default cPanel code. 
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

Note: Be sure to replace example.com with your domain name. Don't forget to Save Changes when finished.