The “unsecure connection” issue occurs when a website is loaded over HTTP instead of HTTPS. This can negatively impact SEO, reduce user trust (as browsers flag the site as “unsecure”), and affect page load speed, since HTTP/2, which offers performance improvements over HTTP/1.1, requires an SSL/TLS certificate to work.

How to Fix the “Unsecure Connection” Issue

1. Apache and LiteSpeed Servers: Add a .htaccess Rule

For Apache and LiteSpeed servers, you can enforce HTTPS by adding a rule to your .htaccess file. This file is located in the root directory of your website. If it doesn’t exist, you can create one. Here’s an example rule:

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

This configuration enables the rewrite engine, checks if HTTPS is off (the connection is not secure), and then redirects requests to HTTPS.

2. Nginx Rule: Add a Server Block Configuration

For websites running on Nginx, you can redirect HTTP traffic to HTTPS by modifying the server block configuration. You can add the following to your Nginx configuration file, typically found at /etc/nginx/nginx.conf or in the /etc/nginx/sites-available/ directory:

server { 
   listen 80;
   server_name example.com www.example.com;
   return 301 https://$server_name$request_uri; 
}

This configuration listens for HTTP (port 80) traffic and redirects all requests to HTTPS using a 301 redirect, which is beneficial for SEO as it passes most of the link equity from the original page.

3. Using Cloudflare: Enable "Always Use HTTPS"

If your website uses Cloudflare, you can easily redirect HTTP traffic to HTTPS without touching server configurations. Follow these steps:

  1. Log in to your Cloudflare dashboard.
  2. Select the domain you want to configure.
  3. Navigate to the "SSL/TLS" tab.
  4. Scroll to the "Edge Certificates" section and find the "Always Use HTTPS" feature.
  5. Turn on "Always Use HTTPS."

This option redirects all HTTP requests to HTTPS at the Cloudflare edge, ensuring that your site benefits from HTTPS without requiring server-side changes.