WordPress多站点SSL配置后主页面重定向异常及后台登录问题求助
Alright, let’s dig into this problem—you’ve got a multisite where the main page is stuck in a redirect loop after adding SSL, but other pages work fine, and you can’t log into the admin panel. You’ve already updated site URLs in the database and are using postname permalinks, so let’s tackle the remaining likely fixes step by step:
1. Lock Down SSL Settings in wp-config.php
Multisite needs specific SSL definitions to avoid redirect conflicts. Open your root wp-config.php file via FTP or cPanel file manager, and add/update these lines:
// Force SSL for admin and login pages define('FORCE_SSL_ADMIN', true); define('FORCE_SSL_LOGIN', true); // Ensure the main site domain uses HTTPS define('DOMAIN_CURRENT_SITE', 'https://mysiteurl.com'); define('PATH_CURRENT_SITE', '/'); // Adjust if using subdirectory multisite // Handle reverse proxies (e.g., Cloudflare, load balancers) if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { $_SERVER['HTTPS'] = 'on'; }
This ensures WordPress recognizes HTTPS requests correctly, which is a frequent cause of loops when servers use proxies.
2. Reset Your .htaccess File for Multisite SSL
Multisite uses a different .htaccess structure than single sites, and old HTTP rules can break redirects. First, back up your existing .htaccess file, then replace it with the appropriate SSL-compatible code:
For Subdirectory Multisite:
RewriteEngine On RewriteBase / # Redirect HTTP to HTTPS (place this before WordPress rules) RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # WordPress multisite rules RewriteRule ^index\.php$ - [L] RewriteRule ^wp-admin$ wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^(wp-(content|admin|includes).*) $1 [L] RewriteRule ^(.*\.php)$ $1 [L] RewriteRule . index.php [L]
For Subdomain Multisite:
RewriteEngine On RewriteBase / # Redirect HTTP to HTTPS (place this before WordPress rules) RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # WordPress multisite rules RewriteRule ^index\.php$ - [L] RewriteRule ^wp-admin$ wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^(wp-(content|admin|includes).*) $1 [L] RewriteRule ^(.*\.php)$ $1 [L] RewriteRule . index.php [L]
After saving, try accessing your main site again—this often fixes loop issues caused by outdated rewrite rules.
3. Clear All Caches (Everywhere)
Old HTTP cached content can keep triggering redirect loops. Make sure to:
- Clear your browser cache (hard refresh with
Ctrl+Shift+RorCmd+Shift+R). - Flush server-level caches (e.g., Apache mod_cache, Nginx fastcgi_cache—check your host’s docs).
- Purge CDN caches if you’re using one (like Cloudflare).
- Disable or rename WordPress cache plugin folders via FTP (e.g., rename
wp-content/plugins/wp-rockettowp-rocket-old) to rule out plugin conflicts.
4. Double-Check Database Entries for HTTP Leftovers
Even if you updated the main site’s URL, multisite stores domain info in additional tables:
- Access your database via phpMyAdmin or a database client.
- Check the
wp_blogstable (replacewp_with your database prefix) — ensure thedomaincolumn for all sites useshttps://mysiteurl.com. - Check each site’s options table (e.g.,
wp_options,wp_2_options,wp_3_options) forsiteurlandhomevalues—they should all behttps://mysiteurl.com.
You can run these SQL queries to spot issues:
-- Check wp_blogs for non-HTTPS domains SELECT * FROM wp_blogs WHERE domain NOT LIKE 'https://%'; -- Check all options tables for non-HTTPS site URLs SELECT * FROM wp_options WHERE option_name IN ('siteurl', 'home') AND option_value NOT LIKE 'https://%'; SELECT * FROM wp_2_options WHERE option_name IN ('siteurl', 'home') AND option_value NOT LIKE 'https://%';
5. Test Direct Admin Access & Refresh Permalinks
Sometimes the main page loop doesn’t block direct admin access. Try visiting https://mysiteurl.com/wp-admin directly—if you can log in:
- Go to Settings > Permalinks.
- Don’t change anything—just click Save Changes. This refreshes your .htaccess file and resets permalink rules, which can fix odd redirect behavior.
6. Verify Server SSL Configuration
If none of the above works, check your server’s SSL setup:
- For Apache: Ensure
mod_sslandmod_rewriteare enabled, and your virtual host config has a proper SSL block pointing to your certificate files. - For Nginx: Confirm your config has a server block listening on port 443 with SSL certs, and a port 80 block redirecting all traffic to HTTPS (like the example below):
server { listen 80; server_name mysiteurl.com www.mysiteurl.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name mysiteurl.com www.mysiteurl.com; ssl_certificate /path/to/your/cert.pem; ssl_certificate_key /path/to/your/key.pem; # Rest of your Nginx config for WordPress }
Start with the wp-config and .htaccess tweaks—those are the most common fixes for multisite SSL redirect loops. If you still run into issues, double-check your database entries and server config carefully.
内容的提问来源于stack exchange,提问作者Archana Sharma

