WordPress redirect hack: why your site redirects to spam
Visitors land on scam or spam sites instead of your website? Here is how the WordPress redirect hack works and how to fix it properly.
A WordPress redirect hack sends your visitors somewhere they never meant to go: fake prize pages, push-notification scams, online casinos or shops selling counterfeit goods. It is one of the most damaging infections because it directly steals your traffic and customers. Here is how the WordPress redirect hack works, how to confirm it and how to fix it for good.
What is a WordPress redirect hack?
In a WordPress redirect hack, attackers inject code that checks who is visiting and sends some or all of them to another site. The code may live in .htaccess, in PHP files such as index.php, wp-config.php or theme files, or as JavaScript stored in the database – in posts, widgets or theme options.
Attackers usually get in through an outdated plugin or theme with a known vulnerability, reused passwords, forgotten admin accounts or another infected site on the same hosting account.

Why you might not see the redirect yourself
A WordPress redirect hack is designed to hide from site owners. The malicious code often:
- skips logged-in administrators
- triggers only for visitors coming from Google or social media
- targets mobile devices only
- runs once per visitor or at random intervals
So if a customer says your site redirected them, take it seriously – even if everything looks fine on your laptop.
How to confirm a WordPress redirect hack
- Open your site on a phone using mobile data and a private browsing window.
- Search for your business in Google and click your result instead of typing the address.
- Check the Security issues report in Google Search Console.
- Look up your domain in Google Safe Browsing.
- Review the list of WordPress administrators for unknown accounts.

How to fix a WordPress redirect hack
- Back up everything first – files and database.
- Clean
.htaccessand core files – replace WordPress core with a clean copy. - Search the database – for injected scripts in posts, options and widgets.
- Check themes and plugins – remove fake or nulled plugins, reinstall the rest from official sources.
- Remove unknown users and change every password and security key.
- Update and harden – firewall, two-factor login, correct file permissions.
- Request a Google review if a warning was shown.
Restoring an old backup alone rarely works: it often contains the same malicious code or brings back the same vulnerability. If you are not sure you found everything, professional WordPress malware removal is the safer option.

Not every redirect is a hack
Sometimes a site redirects because of a misconfigured SSL certificate, an old rule after a domain change or a botched migration. Those cases usually show a redirect loop or a jump to your own old domain – not to unknown advertising sites. A proper diagnosis tells the two apart quickly.

How to prevent a WordPress redirect hack
- update WordPress, plugins and themes regularly, after a backup
- never install nulled plugins or themes
- remove old admin accounts and unused plugins
- use two-factor authentication for all administrators
- keep off-site backups and monitor file changes
Our WordPress maintenance plans cover all of this. You might also want to read our guide to the Japanese keyword hack, which often comes together with redirects.
FAQ
Can a WordPress redirect hack affect only mobile users?
Yes. Many redirect scripts target phones specifically, because owners rarely test their site on mobile data.
Will a security plugin remove a WordPress redirect hack?
Sometimes, but active infections often disable security plugins or hide in the database. A manual review is usually needed.
Is your WordPress site redirecting visitors?
We remove redirect malware remotely and secure your site so it does not come back.
or call: +48 32 444 99 99