0
0
WordpressDebug / FixBeginner · 4 min read

How to Fix Redirect Loop in WordPress Quickly

A WordPress redirect loop usually happens when the Site URL and Home URL settings conflict or when the .htaccess file has incorrect redirect rules. Fix it by ensuring these URLs match and resetting the .htaccess file to default WordPress rules.
🔍

Why This Happens

A redirect loop in WordPress happens when the site keeps sending visitors back and forth between URLs without stopping. This often occurs if the Site URL and Home URL settings in WordPress do not match or if the .htaccess file has wrong redirect rules. This confuses browsers and causes endless redirects.

apache
# Broken .htaccess example causing redirect loop
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

# WordPress settings mismatch example
// In wp-config.php
define('WP_HOME', 'https://example.com');
define('WP_SITEURL', 'https://www.example.com');
Output
ERR_TOO_MANY_REDIRECTS or browser keeps loading endlessly
🔧

The Fix

Make sure the Site URL and Home URL are exactly the same in WordPress settings or wp-config.php. Also, reset the .htaccess file to WordPress default to remove conflicting redirects. This stops the loop and lets your site load normally.

apache
# Correct .htaccess for WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

// In wp-config.php
// Make sure both URLs match exactly
define('WP_HOME', 'https://www.example.com');
define('WP_SITEURL', 'https://www.example.com');
Output
Site loads normally without redirect errors
🛡️

Prevention

Always keep your WordPress Site URL and Home URL consistent, especially after moving your site or changing domain names. Avoid manual edits to .htaccess unless necessary and back it up before changes. Use plugins carefully that modify redirects and test after changes.

⚠️

Related Errors

  • White Screen of Death: Often caused by plugin conflicts or memory limits.
  • 404 Errors: Can happen if permalinks are broken, fix by resetting .htaccess.
  • Mixed Content Warnings: Occur when HTTPS and HTTP content mix, fix URLs to use HTTPS.

Key Takeaways

Ensure WordPress Site URL and Home URL match exactly to avoid redirect loops.
Reset .htaccess to default WordPress rules to fix redirect conflicts.
Backup .htaccess before editing and avoid unnecessary manual redirects.
Test site after changes to catch redirect or URL issues early.
Use plugins that manage redirects carefully to prevent loops.