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

Login loop

Learn 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
Neil McNaught, founder of BugShield and WordPress author
Written by
Written by
Updated
Updated

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.

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 open wp-config.php in your site root, next to wp-admin and wp-content, and override with:

php
define( 'WP_HOME', 'https://www.example.com' );
define( 'WP_SITEURL', 'https://www.example.com' );

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 wp-content/plugins to plugins.disabled via File Manager, SFTP, or FTP. If the loop stops, rename plugins.disabled back to plugins, then deactivate Really Simple SSL, Wordfence, iThemes Security, and custom redirect plugins one at a time in wp-admin until you find the cause.

Step 5: Audit .htaccess redirect rules

Find .htaccess in your site root, next to wp-admin and wp-content. Duplicate HTTPS and www rules 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 fixed price.

Questions answered

WordPress login redirect loop FAQs

Answers about cookies, URL mismatches, caching, security plugins, and restoring reliable wp-admin access.

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 File Manager, SFTP, or 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 File Manager, SFTP, or 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.

What causes a WordPress login redirect loop?

Common causes are stale cookies, mismatched WordPress URLs, conflicting HTTPS detection, cached login pages, security plugins, or an incorrect cookie domain.

Why does clearing cookies fix a WordPress login loop?

WordPress authentication depends on cookies tied to the exact hostname and protocol. Old or conflicting cookies can send a valid login back to the login screen.

How do I check WordPress Address and Site Address without wp-admin?

Inspect WP_HOME and WP_SITEURL in wp-config.php, or check the home and siteurl rows in the options table.

Should WordPress login pages be excluded from cache?

Yes. Exclude wp-login.php, wp-admin, account pages, carts, and checkout from page caching at the plugin, server, and CDN layers.

Can a security plugin cause repeated WordPress login redirects?

Yes. Login hiding, forced two-factor authentication, IP rules, or session controls can redirect authentication. Check its logs and test the plugin safely through file access.

When should a developer fix a WordPress login redirect loop?

Get help when every administrator is locked out, the site uses a proxy or CDN, or changing cookies and URLs could interrupt customer account sessions.

Would you rather a developer fixed it?

Request a fix at a confirmed price and speak directly with the BugShield developer working on your site.

Request a Fix