wordpress 2026-12-02 ⏱ 4 min read

How to Force HTTPS in WordPress

How to Force HTTPS in WordPress

There are three places to force https, and they do different jobs. The site URL tells WordPress what address to generate in links. A server redirect catches visitors who type or follow http links. The admin setting protects the login. Use all three, in this order, after the certificate is working.

Before you start

Confirm that https://yourdomain.com loads without a certificate error. Run the SSL checker if you are not sure. Take a backup first so you can roll back.

Layer 1: The site URL

Go to Settings → General and change both address fields to https. This makes new links, images and scripts use the secure scheme. It does not touch content that already holds an http address. For that, see our mixed content guide.

Force HTTPS in WordPress at the server

ServerWhere to set itNotes
Apache.htaccess in the web rootAbove the WordPress rules
NginxServer block for port 80Needs a reload
Host panelForce HTTPS toggleUse instead of manual rules
CDNPage or redirect ruleDo not duplicate with the origin

Apache example:

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

Nginx example for the port 80 block:

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

Choose a single canonical name, with or without www, and redirect to it so you avoid chains of two redirects.

Layer 3: Secure the admin

Add this line to wp-config.php above the stop-editing comment. It forces https for the login and dashboard:

define('FORCE_SSL_ADMIN', true);

Behind a proxy or CDN

If TLS ends before the request reaches WordPress, the site may think every request is http and loop forever. Pass the forwarded protocol through and tell WordPress to trust it. Details are in our reverse proxy article.

Force HTTPS in WordPress: test it

  1. Run curl -I http://example.com and check for a 301 with a Location header pointing to https.
  2. Run it again on the https address and confirm a 200.
  3. Check there is only one hop in the chain.
  4. Open pages in a private window and look at the Console for mixed content.
curl -I http://example.com
curl -I https://example.com

Optional: HSTS

HSTS tells browsers to use https only. It is helpful and hard to undo, so enable it last. Start with a short max-age, confirm everything works, then raise it. Our security headers guide explains how to review it.

Common mistakes

  • Two redirects from a plugin and the server at once.
  • Forgetting the www name in the certificate.
  • Forcing https in the CDN while the origin forces http.
  • Not clearing caches after the change.

Subdomains and other sites on the same account

A redirect in the web root of the main domain does not cover add-on domains or subdomains that have their own folders. Each one needs its own rule or the host toggle. Check them one by one, including old staging sites that people still visit.

What to do about search engines

Once https works, update the property in Search Console, submit the https sitemap and make sure canonical tags use https. A 301 from http passes ranking signals, so you do not need to do anything dramatic. Leave the redirects in place permanently.

Also check hard-coded links in email templates, social profiles and any outside service that calls back to your site. Those still use the old address and will pass through the redirect until you update them.

Rolling back safely

If something breaks, undo one layer at a time, starting with the one you changed last. Remove the server redirect first, since it is the easiest to restore. Then revert the site URLs through wp-config.php. Keep a copy of the original .htaccess before every edit. Changes of this kind are quick to reverse when you know exactly which line you touched.

Does forcing https slow the site down?

Handshake cost is small, and modern servers reuse sessions. A single redirect adds one short round trip for the first http visit only. Keeping redirects to one hop matters more than the protocol itself.

Can I force https only on the checkout or login?

You can, but it is not worth it. Mixed pages are harder to reason about and browsers treat them as less trustworthy. Move the whole site.

Related reading: fixing WordPress SSL errors, mixed content in WordPress and getting HTTPS for a site from nothing.

Frequently Asked Questions

Which layer should I change first?

The site URL, on a backup, before anything else. Change it while you can still reach the admin, then add the server redirect. Doing it in the other order can lock you out of the admin.

Will forcing HTTPS break my images or theme?

Only if they are hard coded to http. After the redirect, check the browser console for blocked requests and fix each one at its source rather than with a plugin filter.

Do I need HSTS as well?

Not on day one. Add it once the site has run on HTTPS without mixed content for a while, and start with a short max-age so a mistake is easy to undo.

↪️ Generate .htaccess & Nginx 301 HTTPS Redirects
Generate 301 Rules →

✅ Post-Installation Verification & SEO Checklist

After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:

  • Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
  • Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
  • Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
  • Confirm both root and www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

Free SSL Certificates, Live SSL Checker & CSR Generator

Issue trusted Let's Encrypt SSL certificates in 60 seconds with zero server setup.

Related Articles

🤖 TryFreeSSL AI Assistant