DEV Community

Cover image for Forcing Your Website To Serve Secure Content
Giwa Jossy
Giwa Jossy

Posted on

Forcing Your Website To Serve Secure Content

While most hosting plans include an SSL [Secure Sockets Layer] certificate, they are not automatically activated, as you sometimes have to manually install the certificate via the cPanel.

Once installed, you should force a redirect to HTTPS. This encrypts and secures your website’s data, and traffic. It will encourage visitors to engage your site content because they feel safe, and reassured – especially if you’ll be requesting some personal information.

First of all, you need to install the SSL Certificate via the cPanel

  1. Click “SSL/TLS” in the Security category.

    GYRO Design Lab

  2. Click “Manage SSL sites”

    GYRO Design Lab

  3. Now click “Browse Certificate”

    GYRO Design Lab

  4. A window pops up; choose from the list of certificates and click “Use Certificate“. The form-fields get automatically filled.

  5. Now scroll all the way down, and “Install Certificate

Certificate Installed!

Finally! Force a redirect to HTTPS using any of these 2 methods;

  • Method 1:

Is it a wordpress site?

Go to your dashboard and open up the Settings › General tab. You’ll find two fields called WordPress Address (URL) and Site Address (URL). Now replace the HTTP prefix in both fields with HTTPS, and save the changes to your settings: That’s all it takes to configure WordPress to use HTTPS.

  • Method 2:

Edit the .htaccess file

Type the following code into your .htaccess file; create one if you don’t already have one. If you can’t locate it, see how here.

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

Either of these two should help you load serve secure content.

However, enabling HTTPS on your website isn’t enough. If you have mixed content loading over a secure HTTPS connection, you’ll continue to receive mixed or insecure content warnings and push people away. So, take the time to check and monitor your site for insecure content. Because you can bet that even though some site visitors will still risk visiting your site with mixed content warnings, popular browsers like Chrome are going to continue to crack down on insecure sites and prevent users from engaging with them the way you’d like.

Top comments (0)