webzod
account

Redirect HTTP to HTTPS on WordPress

headers.redirect.no_redirect · effort: minutes

Why it matters

Visitors who type the bare domain or follow an old link land on the unencrypted site and stay there. A permanent redirect sends every http request to the same page over https.

Staged change. Do this in stages and check each one before the next, so a mistake does not break your site or your mail.

The fix

  1. Stage 1: set WordPress Address and Site Address to https:// (Settings, General, or the HTTPS button in Tools, Site Health) and check the site works.
  2. Stage 2: redirect at the layer in front of WordPress; many hosts have a Force HTTPS switch. Behind Cloudflare, use Always Use HTTPS and do not add the .htaccess rules, which loop under Flexible mode. On Apache without a CDN, add the rules at the top of .htaccess, above BEGIN WordPress.
.htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Read the documentation (opens in a new tab)

Scan your domain to see whether this applies to you.