How to Force an HTTPS Redirection

November 15, 2022

HOW-TO-FORCE-HTTPS-REDIRECT

We’ve all seen a website with the dreaded “Not Secure” warning in the address bar. It can be very frustrating when this happens to your own website. Many times, a website will have an SSL (secure socket layer) certificate installed on their site, yet this warning will still appear. If this describes you, don’t worry! We’re going to cover how to force http to redirect to https for a secure user experience.

How to Manually Force an HTTPS Redirection using cPanel and .htaccess

Head on into cPanel and click the “File Manager” button and you’ll enter into your site’s file manager. Go into the public html folder and open up your .htaccess file. If you’re not seeing the file, you’ll need to hop into the settings in the top right of the window and make sure that “show hidden files” is selected.

Once you’ve located the .htaccess file, right click and click “edit” so that you can begin editing the file. We’re going to enter a command that will force the https redirect.

Once you’re in the .htaccess file, at the very top, paste the following command:

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

Make sure that you are entering your domain where it says “example.com” exactly as your domain appears on the SSL certificate.

Save your changes and exit out of the file. Navigate back to your site and refresh (note: you may need to clear your cache). You should be seeing the secure lock indicating your site is redirecting to https! Double check by changing the address to http://yoursite.com to know for certain that the http is getting redirected to https.

You should be good to go at this point! If you want to see us walk through these steps in real time, you can watch this video on manually forcing an https redirect to follow along at your own pace!

image832

SEMdeck’s mission is to strengthen up-and-coming brands’ online presence through high quality web design, search engine optimization, content creation, social media management, and pay-per-click advertisements with unrivaled and transparent customer service.