Knowledgebase

KnowledgebaseCloud/VPSCloud HostingFile Management
Back to File Management

How To Force SSL


This article is for cPanel Accounts. Determine where your account is with this guide.

You can force your website to be accessed securely (i.e., require https://) by creating an .htaccess file in the appropriate location (e.g., create this as public_html/.htaccess) including the following mod_rewrite rules:

If you have your own SSL certificate.
Code:

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

Important note: yourdomain.com must match the domain name on your SSL certificate exactly. If your SSL certificate was issued to www.yourdomain.com, for example, then you will need to use www.yourdomain.com in the RewriteRule. If you have a wildcard SSL certificate, you may use %{SERVER_NAME} in the RewriteRule in place of the domain name.

If you are using WestHost's Shared SSL:
Code:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Host} !^YourServerName$
RewriteRule ^(.*)$ https://YourServerName/~YourcPanelUser/$1 [R=301,L]

Related Articles

Am I Responsible For Monitoring My Bandwidth Usage
Can I Add My Own CGI Scripts
Can I Point My Primary Domain To A Sub-folder
Can I Reset My Website Files
Can I Use A .htpasswd File In My Account

Can’t Find what you need?

No worries, Our experts are here to help.