Redirect HTTP to HTTPS in WordPress or htaccess

Move to HTTPS safely: test the certificate, update WordPress, choose one redirect method, then fix redirect loops and mixed content.

Published 1 December 2026

First make sure your https:// address opens without a warning. Take a backup, then change the WordPress addresses to HTTPS. Turn on one redirect. Use your host's HTTPS switch if it has one. The .htaccess rule below is only for Apache hosting without that switch. Do not use both, because two redirects can conflict.

1. Test the certificate before the redirect

Open both addresses below. Replace example.com with your domain:

https://example.com
https://www.example.com

Both need to open without a certificate warning, even if one sends people to the other. If you see a warning, stop and fix the certificate first. Otherwise the redirect will send every visitor to that warning. Your host may already include a no-cost certificate.

2. Save a way back in

Before you change anything:

  • Take a full backup of the files and database, and download it.
  • Save separate copies of .htaccess and wp-config.php on your computer, not in the website folder. wp-config.php contains your database password. If you leave a renamed copy on the server, such as wp-config.txt, anyone could open it.
  • Check that you can open your host's File Manager without using WordPress. If the redirect locks you out, you will need it.
  • Write down both addresses under Settings, then General.

3. Change the WordPress addresses

Open Tools, then Site Health. If the HTTPS item says "Your website does not use HTTPS" and shows Update your site to use HTTPS, use that button. WordPress changes both addresses, then checks that HTTPS is detected. If it is not, WordPress reverses the change.

If there is no button, read the message. If it says HTTPS is not supported, ask your host. If HTTPS works and you can edit both address boxes:

  1. Open Settings, then General.
  2. In WordPress Address (URL) and Site Address (URL), change only http:// to https://. Do not change www or any folder name.
  3. Click Save Changes. You may need to log in again.

If you cannot edit the address boxes, the addresses may be set in wp-config.php. With your saved copy ready, look for existing lines like these:

define( 'WP_HOME', 'https://example.com' );
define( 'WP_SITEURL', 'https://example.com' );

In your own lines, change only http to https, then save. Replace example.com in this sample with your domain, and keep your existing www or folder names. Do not add these lines if they are not there, and do not change any other line.

4. Turn on one redirect

First, think about services that send data to your site, such as payment or courier updates. If one uses an http:// address, change it to https:// in that service's settings and test it. A 301 or 302 redirect can turn the sent data into a normal page request, so the update may be lost.

The host's HTTPS switch

Look in your hosting panel first. In cPanel, open Domains and find Force HTTPS Redirect. It needs a valid SSL certificate. If it will not turn on, ask your host. If you use this switch, skip the code below.

The .htaccess rule

Use this only if your host says the site runs on Apache, mod_rewrite is available, and Apache itself handles HTTPS. Do not use it if Cloudflare, a proxy or a load balancer handles HTTPS first. Use that service's redirect instead, or ask your host.

This rule can also affect other websites kept in folders inside this one, such as another domain or a subdomain. Make sure each one has a working certificate first. A folder with its own rewrite rules may skip this rule, so test a page there too.

Open .htaccess in the website's main folder. Make sure your saved copy is ready, because one mistake can take the site offline. Paste this above # BEGIN WordPress:

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

You do not need to replace anything in this rule. The server fills in the domain and page address.

302 means temporary. Keep it while you test. When every check in step 5 passes, change only 302 to 301, which means permanent, and test again. Browsers can save a 301, so a mistake can stay on a visitor's device even after you correct it.

If the site shows a 500 error, put back your saved .htaccess using File Manager.

5. Test more than the home page

Use a private window. Replace the example addresses with real pages on your site:

http://example.com
http://www.example.com
http://example.com/contact/
http://example.com/a-real-product/

Then check these results:

  • Each one reaches the matching secure page. www may change if your site uses only one version.
  • WordPress login and the contact form both work.
  • The shop checkout works. Use your payment provider's test mode or cash on delivery, then cancel the test order.
  • Printed QR codes open the right page on mobile data.

If you see ERR_TOO_MANY_REDIRECTS

Two settings may be sending the browser back and forth. Check these in order:

  1. Try a private window. If only your normal window fails, delete cookies for that site.
  2. Look for a second redirect in your hosting panel, plugin, proxy or .htaccess. Keep only one.
  3. Compare both WordPress addresses. Both should use https:// and your chosen www or non-www version.
  4. If a proxy handles HTTPS, remove the rule above and use the proxy's redirect. Apache may always see HTTPS as off behind a proxy, so the rule never stops. Ask your host to set up secure HTTPS from the proxy to the server. Do not copy code that trusts X-Forwarded-Proto without asking your host. Visitors can fake that header on some servers.

If WordPress is locked, restore the last file you changed from your backup.

If the page opens but images or design are missing

An HTTPS page may still be asking for HTTP files. This is mixed content. On a computer, open the page in Chrome. Right-click it, choose Inspect, open Console and reload. Look for "Mixed Content" and the file named beside it.

Open that file's address with https://. If it works, correct the link where you added it, such as a logo, theme setting or pasted code. If not, replace or remove it. Browsers may upgrade some images, audio and video, but they block insecure scripts, styles and frames.

Common questions

Will this redirect stop my SSL certificate from renewing?

A normal redirect should not stop Let's Encrypt's web check. That check starts on port 80 and can follow a redirect to HTTPS. Keep port 80 open, and do not block /.well-known/acme-challenge/.

Should I use a plugin for the HTTPS redirect?

Only if you cannot use your host's switch or edit server files. Check that it is maintained and works with your WordPress version. Do not add a second redirect.

Will my old Google links still work?

Yes, if each old address redirects to its matching HTTPS page. Google uses a permanent redirect as a sign that the new address should appear in search. Keep the rest of each address the same. Search results may take time to change.

Sources

Read next

Check a domain name