Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Troubleshooting

Why Is Your WordPress Website Redirecting? Causes and Fixes

Why Is Your WordPress Website Redirecting? Causes and Fixes

Short answer

Usually the cause is wrong site URL settings, HTTPS or www rules that clash, or a redirect plugin rule. Other causes are .htaccess rules, CDN settings, cached old redirects, registrar forwarding or malware that sends visitors to spam sites.

Key takeaways

  • Note where the redirect goes, since it points to the cause.
  • Check the redirect chain in the browser Network tab.
  • Mismatched site URLs are common after migrations.
  • HTTPS loops often come from CDN and SSL plugin clashes.
  • Redirects to spam sites almost always mean malware.
  • Clear every cache layer after fixing a redirect.

Why is your WordPress website redirecting?

A WordPress website usually redirects because of wrong site URL settings, forced HTTPS or www rules, a redirect plugin, a CDN setting, a cached old redirect, or malware sending visitors to another site.

Some redirects are normal. WordPress sends http visitors to https, adds or removes www, and fixes small typos in post addresses. You only have a problem when the redirect goes somewhere you did not expect, or never ends.

Start by noting where the redirect goes. That one detail points to the cause faster than anything else.

Where it sends youMost likely cause
A spam, pharmacy or gambling siteMalware or a hacked plugin
Your old domain or a staging URLSite URL settings or leftover migration data
The same page again and againRedirect loop from HTTPS, CDN or cache rules
The login pageMembership, maintenance or privacy plugin
A different page on your siteRedirect plugin rule or SEO plugin redirect
Your domain with or without wwwNormal behaviour, or a mismatch causing a loop

How can you see where a redirect goes?

Open your browser's developer tools, go to the Network tab, load the page and read the status codes and Location headers for each step in the chain.

Each redirect shows up as a 301, 302, 307 or 308 response. The Location header tells you the next address. MDN's guide to HTTP redirections explains what each code means.

If you are comfortable with a terminal, this command shows the same thing:

curl -sIL https://example.com | grep -iE "^(HTTP|location)"

Also look at the server or x- headers. They often reveal whether the redirect came from WordPress, your web server, or a CDN such as Cloudflare.

Test in a private window too. Browsers cache 301 redirects hard, so an old rule can keep firing on your computer after you have fixed it.

Are your WordPress site URLs set correctly?

Wrong values in Settings > General for the WordPress Address and Site Address are a top cause of redirects, especially after a migration or domain change.

WordPress stores two addresses, called siteurl and home. When either points at an old domain, a staging site or the wrong protocol, WordPress redirects visitors there.

Check them:

  1. Go to Settings > General.
  2. Look at WordPress Address (URL) and Site Address (URL).
  3. Make sure both use your live domain and the same http or https.

If you cannot reach the dashboard, check wp-config.php for hard-coded WP_HOME and WP_SITEURL lines. You can also edit the values in the wp_options table with phpMyAdmin.

After a migration, old URLs can also linger inside posts and settings. A search and replace tool fixes those. Our guide on WordPress not working after changing the site URL covers the full recovery process.

Is HTTPS or www forcing causing a loop?

Redirect loops often come from two systems disagreeing about HTTPS or www, such as an SSL plugin forcing https while a CDN or server sends visitors back to http.

You will usually see a browser error such as too many redirects when this happens. The page bounces between two addresses until the browser gives up.

Common clashes include:

  • An SSL plugin and an .htaccess rule both forcing HTTPS in different ways
  • Cloudflare Flexible SSL mode while WordPress forces HTTPS
  • A host setting that adds www while WordPress settings remove it
  • A load balancer that does not tell WordPress the visitor used HTTPS

With Cloudflare, Full or Full (strict) mode is usually the fix when your server has a certificate. Cloudflare's guide to SSL/TLS encryption modes explains each one. Our guide on fixing a Cloudflare redirect loop walks through the settings.

For a full list of loop causes, read what causes too many redirects.

Could a rule in .htaccess be redirecting visitors?

Yes, rewrite rules in the .htaccess file can redirect visitors before WordPress even loads, so check it for old domain rules, HTTPS rules and anything you do not recognise.

On Apache and LiteSpeed servers, .htaccess sits in your site's root folder. WordPress adds a standard block for permalinks. Hosts, cache plugins and SSL plugins often add more.

Look for lines starting with RewriteRule or Redirect that mention another domain. Malware also hides redirect rules here, sometimes far down the file after many blank lines.

Make a copy before you edit. Then remove suspect rules and test again. The WordPress Apache HTTPD guide shows what the default WordPress block looks like.

Our guide on editing the .htaccess file explains how to reach it safely. Nginx servers do not use .htaccess, so ask your host to check the server config instead.

Is a redirect plugin or SEO plugin sending visitors elsewhere?

A redirect rule in a plugin such as Redirection, Yoast SEO Premium or Rank Math can send a page to the wrong place, especially after slugs change or rules are imported.

Check each tool that can create redirects:

  • The Redirection plugin under Tools > Redirection
  • Rank Math under its Redirections screen
  • Yoast SEO Premium under its Redirects screen
  • Any maintenance, coming soon or membership plugin

Search the rule lists for the page that redirects. Look out for wildcard or regex rules, as one broad rule can catch many pages.

Our guide on using the Redirection plugin shows how to read and edit its rules.

Membership and privacy plugins often send logged-out visitors to a login page on purpose. If only some pages redirect to login, check their access settings first.

Is malware redirecting your website?

If visitors land on spam, adult, gambling or fake prize pages, especially on mobile or from search results, your site is very likely hacked and needs cleaning.

Malware redirects are sneaky. They often fire only for first-time visitors, only on mobile, or only when someone arrives from Google. You may never see it while logged in.

Warning signs include:

  • Strange code at the top of theme files or index.php
  • Unknown admin users
  • New plugins you did not install
  • Odd scripts injected into posts or the wp_options table
  • Search results showing spam titles for your site

Scan the site straight away. Our guide on scanning WordPress for malware lists the tools to use.

Then follow fixing a site redirecting to another site for the full clean-up.

After cleaning, change every password, update all plugins and themes, and remove any software you no longer use.

Could caching or DNS be causing the redirect?

Yes, a page cache or CDN can keep serving an old redirect after you fix the cause, and domain forwarding at your registrar can redirect visitors before they reach your host.

Clear every cache layer in order:

  1. Your caching plugin
  2. Your host's server cache
  3. Your CDN, such as Cloudflare
  4. Your browser, or test in a private window

Then check your domain registrar. Some registrars offer domain forwarding, which sends the domain to another address. If it is switched on, it overrides your hosting completely.

Also check your DNS records point to the right server. An old A record can send visitors to a previous host that still redirects.

How do you stop the redirect for good?

Find the layer that sends the redirect, fix the rule there, clear all caches, and test with a fresh browser and a header check tool.

A simple order to work through:

StepWhat to check
1Network tab or curl to see the full redirect chain
2Settings > General site URLs
3wp-config.php for WP_HOME and WP_SITEURL
4.htaccess or server config rules
5Redirect, SEO, SSL and membership plugins
6CDN and SSL mode settings
7Registrar forwarding and DNS
8Malware scan if the target is an unknown site

If you planned a redirect on purpose, such as moving a page, use a 301 for permanent moves. Our explainer on what a 301 redirect is covers when to use each type.

Frequently asked questions

Why does my WordPress site redirect to another website?

If it goes to a site you do not own, malware is the most likely cause. Hackers add redirect code to theme files, .htaccess or the database. Scan the site, remove the code, update everything and change all passwords.

Why does my site redirect to my old domain?

The site URLs in Settings or wp-config.php still point to the old domain, or old URLs remain in the database after a move. Update both addresses, then run a search and replace on the database to change remaining links.

Why does the redirect only happen on my phone?

Mobile-only redirects are a common malware trick, since site owners usually check on desktop. They can also come from a mobile theme plugin or a separate mobile cache. Scan for malware first, then check mobile settings in your cache plugin.

How do I clear a cached redirect in my browser?

Browsers store permanent redirects. Clear your browsing data for the site, or test in a private window or another browser. If a fresh browser shows the correct page, the problem was only your local cache.

Is it bad for SEO when my site redirects?

Planned 301 redirects are fine and help search engines follow moved pages. Redirect loops, chains and redirects to spam sites hurt rankings and trust. Fix loops quickly and clean malware before search engines flag the site.

Sources

  1. Redirections in HTTP MDN Web Docs
  2. Apache HTTPD and .htaccess WordPress Developer Resources
  3. SSL/TLS encryption modes Cloudflare Docs
  4. Redirection plugin WordPress.org Plugins

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.