From time to time we are asked how you can force your website visitors to view your website over https. For example, if a visitor access http://domain.com, you can force them to https://domain.com so that they are always using the SSL certificate.

Please note, if you use the Premium Website Builder to create your site, please see our article on How to Force your Premium Website Builder site to use SSL.

How to force your visitors to use your Shared SSL Certificate

To force your visitors to use your Shared SSL certificate:

  1. log into your cPanel and access the redirects section
  2. Set "Type" to "Permanent (301)"
  3. Next to "http://(www.)?" choose the domain name you are working with
  4. Next to "redirects to", enter your website's url using the Shared SSL Certificate
  5. We recommend having "Redirect with or without www." selected, so that the user will be forced to use SSL whether they use domain.com or www.domain.com
  6. Ensure "Wild Card Redirect" is selected
  7. Click "Add"

When testing, we were redirecting whhsupport.com to https://secure21.webhostinghub.com/~whhsup5/

You can see below how the rewrite was setup before we clicked "Add"

force_https_cpanel

 

When you save this redirect, cPanel actually sets up the redirect by editing your .htaccess file. You don't need to do anything further from here (other than test). If you were actually looking for the .htaccess code to perform this type of redirect, cPanel added the following code to the .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^whhsupport.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.whhsupport.com$
RewriteRule ^(.*)$ "https\:\/\/secure21\.webhostinghub\.com\/\~whhsup5\/$1" [R=301,L]

How to force your visitors to use your Dedicated SSL certificate

If you try to setup a Dedicated SSL redirect using the same steps above, cPanel will fail with an error message, similar to:

Redirecting to https://www.whhsupport.com/ will cause a redirection loop because 'http://whhsupport.com/'

which is located at /home/whhsup5/public_html/

is above 'https://www.whhsupport.com/'

which is located at /home/whhsup5/public_html/

Because of this, we'll need to edit the .htaccess file manually. Using File Manager (or your editor of choice), edit public_html/.htaccess and add the following code:

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

Be sure to replace www.domain.com with your actual domain name. For example, if your domain name is whhsupport.com and you want to force redirection to https://www.whhsupport.com

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.whhsupport.com/$1 [R,L]
Did you find this article helpful?

Login to comment.

Your Opinion Matters

... but we need to know what you're thinking!

The Community Support team wrote the article you're looking at now. We like to think it's perfect, but we're sure you have some suggestions. Please, let us know what they are!

Feedback
Your Email Address
Because we'd like to talk with you!

Have a Question?

If you need some help, submit your question to our Community! We guarantee a response within 60 minutes (8am - 9pm EST, Monday - Friday)

Recent Questions

  1. Error in sending mails from my email account
  2. I can't connect to the server with filezilla
  3. Can't login to email

Support Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.