Forcing Your Website to Use HTTPS

Print
  • 0

Why this matters

Your website has a free SSL certificate, so it works over a secure https connection, the one with the padlock. But having a certificate and forcing everyone onto the secure version are two different things. Without forcing it, visitors can still reach the old, unencrypted http version of your site, and search engines may still see two versions of every page. Forcing https means every visitor, every time, lands on the secure version, no matter how they arrived.

This is worth doing for every site. It is better for security, better for search ranking, and it clears the "Not Secure" warning browsers show on unencrypted pages.

Check one thing first

Before forcing https, make sure your site actually loads correctly over https already. Type https://yourdomain.tld into your browser and confirm the site appears with a padlock and no certificate warning. On our hosting the free certificate is issued automatically, so this is almost always fine, but checking takes five seconds and saves a headache.

If https shows a certificate warning instead of your site, stop here, do not force https yet, because you would be redirecting visitors to a version that is not working. Sort the certificate first, our article on SSL certificate warnings covers it, or open a support ticket and we will check it.

The easy way: let WordPress or a plugin handle it

If your site runs WordPress, the simplest route is often a plugin. A plugin such as "Really Simple SSL" detects your certificate and forces https across the whole site with essentially one click, and it also helps with the mixed-content issue covered in our article on fixing "Not Secure" warnings. For most WordPress owners this is the path of least resistance, and it undoes cleanly if you ever need to.

The manual way: the .htaccess file

For non-WordPress sites, or if you prefer to do it directly, https is forced with a few lines in your site's .htaccess file, a hidden configuration file in your website's main folder that controls how the server handles requests.

  1. Log in to cPanel at yourdomain.tld/cpanel and open File Manager, as our cPanel tour describes.
  2. Go into your site's folder, usually public_html.
  3. Make hidden files visible, in File Manager's Settings, tick Show Hidden Files (dotfiles), because .htaccess starts with a dot and is hidden by default.
  4. Before editing, make a copy of the existing .htaccess file if there is one, right-click it and Copy, so you can restore it if anything goes wrong. This matters, because a mistake in .htaccess can take the whole site offline, as our article on internal server errors explains.
  5. Edit the file and add these lines at the top:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Save, then test by visiting the plain http://yourdomain.tld version, it should redirect you automatically to the https version. Test the site properly afterwards, a few pages, not just the homepage, to confirm everything still works.

If something breaks

If the site shows an error after editing .htaccess, the usual cause is a small mistake in the file or a conflict with lines already there. Restore the copy you made, and the site returns to how it was. If you did not make a copy, or you are not comfortable editing the file, open a support ticket, forcing https is a routine thing for us to set up, and we would far rather do it for you than have you wrestling with a file that can take a site down. A "redirect loop" error, where the browser says the page redirected too many times, is a specific sign the rule has clashed with another setting, and is worth sending straight to us.

Good to know

Forcing https is one of those jobs you do once per site and never think about again, and every site should have it done. If you run several sites with us and want them all forced to https properly, tell us and we will handle the lot, it is quick at our end. And once https is forced, keep an eye out for the "Not Secure" warning still appearing on some pages, that is usually mixed content rather than a certificate problem, and our article on fixing "Not Secure" warnings explains the difference and the fix.


Was this answer helpful?

« Back

Powered by WHMCompleteSolution