Skip to content

Kompile Learn

Redirect HTTP to HTTPS

Send every http:// request to the same https:// address with a permanent redirect.

What it is

People type your address without https, and old links point at http. A permanent (301 or 308) redirect moves them to the encrypted version.

Why it matters

Visitors who land on the plain HTTP version can have their traffic read or changed before they ever reach the secure site.

How to fix it

nginx

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

Apache (.htaccess)

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

Cloudflare

SSL/TLS > Edge Certificates > Always Use HTTPS: On

Does your site have this problem?

Kompile Scan checks for this and the other problems in these guides in under a minute. Free for one site.

Check my site