Skip to content

Tutorials Security Beginner1 min read

How to Force HTTPS and Redirect All Traffic to SSL

Redirect every visitor from HTTP to HTTPS with cPanel’s Force HTTPS setting or .htaccess, choose www or non-www, and add HSTS safely.

By ZSOLNET Editorial Team Updated

Key takeaways

  • Use one permanent redirect from HTTP to HTTPS.
  • Behind a CDN, redirect at the CDN to avoid loops.
  • Roll out HSTS with a short max-age first.

Once your site has an SSL certificate, send every visitor to the secure version with a single permanent redirect.

Option 1: cPanel

Open Domains, find the domain and switch on Force HTTPS Redirect. The toggle is only available when the domain has a valid certificate.

Option 2: .htaccess

Add this near the top of .htaccess in the document root:

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

To also standardise on the bare domain in one hop:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

WordPress

Also update Settings → General so both addresses start with https://, then fix any mixed content.

Add HSTS (optional)

HTTP Strict Transport Security tells browsers to always use HTTPS for your domain:

Header always set Strict-Transport-Security "max-age=31536000"

Start with a short max-age (such as 300) to test, and only add includeSubDomains once every subdomain supports HTTPS.

Share X LinkedIn Facebook

Log in to your account

Manage your domains, hosting and invoices in one place.

Secure connection straight to the ZSOLNET client area.

No account yet?