Resolving HTTPS Redirect Loops and Mixed Content in WordPress Multisite
Content
Migrating a WordPress Multisite network to HTTPS or troubleshooting SSL issues can be a complex process. A common challenge users face is the redirect loop, where the site gets stuck in an endless cycle of redirects between HTTP and HTTPS. Other frequent issues include mixed content warnings, where some resources are still loaded over HTTP, and problems with new subsites not defaulting to HTTPS. This guide explains why these problems occur and provides the most effective solutions based on community experience.
Why Do HTTPS Redirect Loops Happen in Multisite?
Redirect loops often stem from conflicting instructions. Your WordPress configuration, database entries, server rules (like those in an .htaccess file), and caching plugins can all be trying to manage the HTTP-to-HTTPS redirect. When these settings are not fully synchronized, they can conflict with each other, creating a loop. Common causes include:
- Incomplete URL updates in the database after migrating to HTTPS.
- A redirect rule in the
.htaccessfile that conflicts with a rule set by a plugin or your hosting provider. - Hardcoded HTTP URLs in theme or plugin files.
- Cached pages or cookies that still reference the old HTTP protocol.
Common Solutions for HTTPS Redirects and Mixed Content
1. Perform a Complete Database Search and Replace
The most critical step is to ensure every instance of your old HTTP URL is updated to HTTPS in the database. This includes serialized data where URLs are stored. For a Multisite network, you must update the URLs for the main site and every subsite.
- Tool: Use a reliable, trusted plugin like Better Search Replace.
- Process: Always back up your database first. Then, run a search for
http://example.comand replace it withhttps://example.com. Repeat this process for all variations of your domain (e.g., with and without www). - Caution: Avoid using unsupervised search-and-replace scripts, as they can break serialized data if not handled correctly.
2. Review and Update Your .htaccess File
Incorrect or duplicate redirect rules in your .htaccess file are a primary cause of loops. The 'Networking WordPress' team suggests that for a standard WordPress Multisite subdomain setup, your .htaccess file should resemble the code found in the official documentation. If you have added custom redirects, ensure they do not conflict. A common and simple rule to force HTTPS is:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Place this rule above the standard WordPress rewrite rules.
3. Force HTTPS for New Multisite Subsites
By default, new sites created in a Multisite network may not use HTTPS, even if the main site does. To automatically force HTTPS for all new subsites, you can use a Must-Use plugin. Create a file like force-https-multisite.php in your /wp-content/mu-plugins/ directory with the following code:
<?php
// Force HTTPS for new sites in a Multisite network
add_filter( 'wp_initialize_site_args', 'force_https_for_new_sites', 10, 2 );
function force_https_for_new_sites( $args, $site ) {
$args['options']['home'] = 'https://' . $site->domain;
$args['options']['siteurl'] = 'https://' . $site->domain;
return $args;
}
?>
4. Configure WordPress for a Reverse Proxy
If your WordPress site is behind a reverse proxy (like nginx or a load balancer) that handles SSL termination, WordPress might not detect that it's being accessed over HTTPS. This can cause redirect loops and mixed content. To fix this, add the following lines to your wp-config.php file, above the line that says /* That's all, stop editing! Happy publishing. */:
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
$_SERVER['HTTPS'] = 'on';
}
5. Clear Caches and Cookies
After making these changes, clear all caching from any caching plugins, server-side caches (like Varnish or OPcache), and your browser. Also, clear your browser's cookies and local storage for the site, as old session data can perpetuate redirect loops.
When to Seek Further Help
If these steps do not resolve the issue, the problem may be more specific to your server configuration. In these cases, it is recommended to:
- Check your server's error logs for more detailed clues.
- Temporarily deactivate all plugins and switch to a default theme to rule out conflicts.
- Consult your hosting provider to confirm that your SSL certificate is installed correctly and that their server configuration is not causing a conflict.
Successfully implementing HTTPS across a Multisite network requires careful attention to detail in the database, WordPress configuration, and server settings. Following these structured steps should help you achieve a secure and properly functioning site.
Related Support Threads Support
-
Creating One Page from HTTPS to HTTPhttps://wordpress.org/support/topic/creating-one-page-from-https-to-http/
-
Requests forwarded to non existing IPhttps://wordpress.org/support/topic/requests-forwarded-to-non-existing-ip/
-
Migrate to https a multisite wordpresshttps://wordpress.org/support/topic/migrate-to-https-a-multisite-wordpress/
-
Wildcard SSL and new site creationhttps://wordpress.org/support/topic/wildcard-ssl-and-new-site-creation/
-
redirect loop issuehttps://wordpress.org/support/topic/redirect-loop-issue-3/
-
How do I change the base URL?https://wordpress.org/support/topic/how-do-i-change-the-base-url/
-
WordPress Multisite Forwarding non-https to Main Sitehttps://wordpress.org/support/topic/wordpress-multisite-forwarding-non-https-to-main-site/
-
wordpress in docker behind nginx reverse proxyhttps://wordpress.org/support/topic/wordpress-in-docker-behind-nginx-reverse-proxy/
-
Why don’t I have “Domain Mapping” in settingshttps://wordpress.org/support/topic/why-dont-i-have-domain-mapping-in-settings/
-
Multisite move domain: old htpps links not workinghttps://wordpress.org/support/topic/multisite-move-domain-old-htpps-links-not-working/
-
Each alias (subdomain) uploads http not httpshttps://wordpress.org/support/topic/each-alias-subdomain-uploads-http-not-https/
-
How to move a multisite from http to httpshttps://wordpress.org/support/topic/how-to-move-a-multisite-from-http-to-https/
-
Mulisite ssl problemhttps://wordpress.org/support/topic/mulisite-ssl-problem/
-
set default siteurl to HTTPS in multisitehttps://wordpress.org/support/topic/set-default-siteurl-to-https-in-multisite-2/
-
Redirect to http in Subdirectory on https Sitehttps://wordpress.org/support/topic/redirect-to-http-in-subdirectory-on-https-site/
-
Nginx with forced https – guidance found only for httphttps://wordpress.org/support/topic/nginx-with-forced-https-guidance-found-only-for-http/
-
Adding nofollow to all links to wp-admin on a multisitehttps://wordpress.org/support/topic/adding-nofollow-to-all-links-to-wp-admin-on-a-multisite/
-
https://www.***.com get https://www.***.com/https://www.***.com error 404https://wordpress.org/support/topic/https-www-com-get-https-www-com-https-www-com-error-404/
-
Redirect from non www to wwwhttps://wordpress.org/support/topic/redirect-from-non-www-to-www-2/
-
Change the site URLhttps://wordpress.org/support/topic/change-the-site-url-3/
-
How to set up CSP in nginx reverse proxyhttps://wordpress.org/support/topic/how-to-set-up-csp-in-nginx-reverse-proxy/
-
Mixed content – request has been blocked: the content must be served over HTTPShttps://wordpress.org/support/topic/mixed-content-request-has-been-blocked-the-content-must-be-served-over-https/
-
HTTPS multisite Sitegroundhttps://wordpress.org/support/topic/https-multisite-siteground/
-
Wildcard forward all posts and pages with few exceptionshttps://wordpress.org/support/topic/wildcard-forward-all-posts-and-pages-with-few-exceptions/