Understanding Redirect Loops
Browser gets stuck in endless redirects (HTTP 301/302 circles).
Common Causes
- HTTPS redirect misconfiguration
- WordPress URL settings mismatch
- Load balancer/proxy header issues
- Cookie/authentication redirect conflicts
Fix 1: Check HTTPS Configuration
Ensure you're not redirecting HTTP→HTTPS with HTTPS also redirecting:
# In Nginx - incorrect:
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
return 301 http://$host$request_uri; # Causes loop!
}
Remove the second redirect.
Fix 2: WordPress URL Settings
Check wp-admin → Settings → General:
- WordPress Address (URL)
- Site Address (URL)
Both must match (both http:// or both https://).
If locked out, edit wp-config.php:
define('WP_HOME', 'https://yourdomain.com');
define('WP_SITEURL', 'https://yourdomain.com');
Fix 3: Check .htaccess for Conflicts
Temporarily rename:
mv .htaccess .htaccess.bak
If loop stops, regenerate permalinks.
Fix 4: Check Proxy/Load Balancer Headers
For Nginx behind proxy:
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
For applications reading X-Forwarded-Proto to detect HTTPS.
Fix 5: Check Cookies
Clear browser cookies. Sometimes corrupted cookies cause redirect loops.
Debug Redirects
# Check with curl
curl -I http://yourdomain.com
curl -L http://yourdomain.com # Follow redirects
# View all redirect steps
curl -L --trace-ascii - http://yourdomain.com