WordPress redirect hack: when only some visitors get sent to spam

Updated 2026-10-16 · 7 min read · by the IsHacked team

A customer tells you your site sent them to a lottery or a "your phone is infected" page. You open it and everything is fine. Redirect malware is built to behave exactly like that.

Test redirects for phones and Google visitors

Why you can't reproduce it

Reproduce it

curl -sI -A 'Mozilla/5.0 (Linux; Android 14; Pixel 8) Mobile Safari/537.36' \
  -e 'https://www.google.com/' https://example.com/

Look at the status and Location header. If the redirect is done in JavaScript, fetch the page body instead and search for location.href, window.location.replace or document.referrer near a foreign URL. On a real phone, use a private tab on mobile data and arrive from a Google search result.

Where the code hides in WordPress

Fix it

Remove the redirect code, then find how it got in, because these infections reinstall themselves from cron jobs and hidden copies. The cleanup checklist covers every place we have found persistence. Afterwards, keep checking as a phone visitor from Google every day: that is the only way to notice the next one before your visitors do.

FAQ

Why does the redirect not happen to me?

Redirect malware deliberately skips logged-in users and administrators, often skips desktop browsers and direct visits, and usually fires only once per visitor using a cookie. Test from a private window on a phone, arriving from a Google search.

Can a plugin cause a redirect without being hacked?

Yes: a misconfigured redirect or security plugin, a wrong site URL in Settings, or a CDN rule. Malicious redirects go to unrelated domains (lotteries, fake updates, adult or betting sites), not to another page of your own site.

Related guides

How to check if your website is hacked

12 practical tests to tell if a website or WordPress site is hacked: cloaked spam, mobile-only redirects, injected scripts and exposed files.

Hacked WordPress cleanup checklist: every place malware hides

Step-by-step cleanup for a hacked WordPress site: backdoors in mu-plugins and uploads, fake plugins, cron, database payloads and rogue admins.

SEO spam and cloaking: casino and pharma links only Google can see

Casino, slot or pharma titles in Google for your site? How SEO spam cloaking works, how to see what Googlebot sees, and how to clean it up.

Send feedback

A bug, an idea, a question about this page: anything. It goes straight to the founder.