New 24/7 monitoring and daily cloud backups now included in every Shield Pro plan.

Login loop

How to fix a WordPress login redirect loop

A login redirect loop sends you back to wp-login.php after every successful sign-in. Mismatched URLs, HTTPS settings, and security plugins are the usual causes. This tutorial fixes URL constants, cookies, and .htaccess without locking yourself out.

Time: 20-40 minutes Level: Intermediate

What this problem looks like

WordPress sets authentication cookies for the URL defined in siteurl. If you log in at https://www.example.com but siteurl is https://example.com, cookies may not stick and you loop forever.

Redirect loops also follow bad HTTPS rules in .htaccess, reverse proxy headers, and security plugins that force SSL on wp-admin incorrectly.

When editing wp-config.php to fix URLs, use the exact hostname visitors use. Changing www to non-www without redirects creates new loops.

Step 1: Clear cookies and test private browsing

Old http cookies conflict after SSL migration. Clear site data in browser settings or use a private window. Try both www and non-www URLs to see which loops.

Step 2: Fix siteurl and home in the database or wp-config

In phpMyAdmin, open wp_options and set siteurl and home to your live https URL. Or override in wp-config.php:

php
define( 'WP_HOME', 'https://www.example.com' );
define( 'WP_SITEURL', 'https://www.example.com' );
WP_HOME and WP_SITEURL in wp-config.php override the database. Use them when the database values are wrong and admin loops.

Step 3: Fix HTTPS detection behind proxies

Behind Cloudflare or a load balancer, WordPress may think the request is http. Add to wp-config.php when your host documents it:

php
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
	$_SERVER['HTTPS'] = 'on';
}

Step 4: Deactivate security and redirect plugins

Rename folders for Really Simple SSL, Wordfence, iThemes Security, and custom redirect plugins in wp-content/plugins/. Reload wp-login after each test.

Step 5: Audit .htaccess redirect rules

Duplicate HTTPS and www rules in .htaccess cause loops. Keep one canonical redirect chain. Temporarily rename .htaccess to test whether server rules conflict with WordPress.

When to stop DIY and hire help

Login loops on live shops waste orders every minute. BugShield fixes WordPress login and HTTPS cookie issues at a confirmed price with secure Vault access.

FAQs

Why does login work on staging but not production?

Production may have different siteurl, CDN SSL mode, or security plugins. Compare wp_options and .htaccess between environments.

Can I fix login loop without database access?

Yes if you can edit wp-config.php via FTP. Define WP_HOME and WP_SITEURL there to override bad database URLs.

Does Really Simple SSL cause loops?

It can when SSL is already forced at server and CDN layers. Deactivate via FTP and test with a single redirect layer.

Should COOKIE_DOMAIN be set in wp-config?

Usually leave it unset. Wrong COOKIE_DOMAIN values break login cookies on subdomains and www variants.

Rather someone else fixed it?

Request a fix at a confirmed price. Named UK developer, secure Vault, direct chat.

Request a Fix