WordPress redirecting to spam sites
Visitors land on somebody else's site, and Google shows spam where your offer used to be. That is a break-in, not a fault - and cleaning the files alone will not hold.
The symptom is distinctive: you type your own address and the browser lands somewhere else. Sometimes it happens only on arrivals from Google, sometimes only on a phone, and from your own computer everything looks normal — because the malicious code recognises the administrator and spares them.
This is not a fault. Redirects to unknown addresses mean somebody has access to your site. The target is usually the traffic and the rankings you built, which is why the attacker works hard to keep the infection unnoticed.
Before you start: contain it
- Take a full copy of files and database. Even an infected one — you will want it for analysis and as a fallback.
- Change the passwords: WordPress admin, FTP/SSH, database and hosting panel. Skip this and you will clean up only for the code to return the same way.
- Check the user list in the panel. Delete any administrator accounts you did not create.
Where the malicious code hides
In practice, almost always in several of these places:
- Theme files, most often
header.php,footer.phpandfunctions.php— an appended block of JavaScript or a long base64-encoded string. - The
wp_optionstable, in thesiteurlandhomefields. A foreign address there is the first thing to correct. - The
wp_poststable — scripts injected into post content. - The
.htaccessfile — rules that redirect traffic arriving from search engines. - Dropped files with innocent names in
wp-content/uploads. A directory for images should not contain a single.phpfile.
With SSH access, it is worth starting from the usual patterns:
grep -rn "base64_decode\|eval(" wp-content/ --include="*.php" | head -50
find wp-content/uploads -name "*.php"
Cleaning up
The most reliable approach is replacing everything replaceable rather than cutting out fragments:
- Download a clean WordPress package and overwrite
wp-adminandwp-includesentirely. - Reinstall plugins and the theme from official sources. You do not heal an infected plugin — you replace it.
- In the database, correct
siteurlandhome, then review content for injected scripts. - Regenerate
.htaccessby saving the permalink settings. - Remove every PHP file from the
uploadsdirectory.
The step that matters most: close the way in
This is the stage most often skipped — which is why the infection comes back within days. The attacker arrived through one of these:
- an outdated plugin or theme with a known vulnerability (by far the most common),
- a weak administrator or FTP password,
- another, neglected site on the same hosting account,
- an abandoned plugin that no longer receives fixes.
Look through the access logs from around the time the redirects started. Watch for POST requests to unusual addresses and hits on files that should not exist. That usually reveals the route.
After the clean-up
Submit the site for review in Google Search Console, under Security issues. Without that, the warning in search results can linger for weeks even though the site is already clean. Keep watching over the following days in case anything returns.
Enable automatic updates at least for security releases, and delete plugins you do not use. A deactivated plugin still sits on the server and can still be a way in.
Not working out?
If the problem stays, or you would rather not experiment on a live site, write to us and we will look at it. The diagnosis costs nothing.
WordPress supportOther guides
Drupal 10 reaches end of life
Drupal 10 stops receiving security fixes on 9 December 2026. If your site runs on it, you have weeks left to decide - and the cost depends mostly on which version you are starting from.
Getting started with AI in your company
Most failed AI projects do not fall over on the technology, but on the choice of process. So we start with what is countable and repetitive, not with what looks most impressive.
A slow website
A slow site is never one fault, it is the sum of several. We start by measuring, because without that optimisation is guesswork - and usually speeds up what was already fast.
An expired SSL certificate
Instead of your site, visitors get a red warning and have to click through "proceed anyway". Most of these cases are an expired certificate or a renewal that never finished.
Moving a website to new hosting
A migration goes well or badly depending on the order of the steps. The most expensive mistake is switching DNS before checking that the site works on the new server at all.
The WordPress 500 error
HTTP 500 is the server saying something interrupted the code. On its own it tells you nothing - the whole job is getting to the log.
The WordPress white screen
Instead of your site you get blank white. It is one of the most common symptoms, and in most cases it can be defused in a quarter of an hour.