Clearing Hacked WordPress Spam From Google After a Migration
Key takeaways: cleaning hack spam out of Google after a migration
- A migration does not remove a hacked site's spam from Google. Google keeps the injected URLs indexed until Googlebot crawls them again.
- On this site, 103 injected gambling pages brought 29 of 67 search clicks in the 28 days after launch.
- We built the legacy URL list from Google Search Console, the Wayback Machine and Ahrefs, then verified 134 of 134 redirects on the live site.
- A temporary recrawl sitemap of 237 URLs got Google to refetch the dead pages. Spam clicks fell from 24 in early September to 3 in early October.
- With the spam filtered out of reporting, the site's real 28-day clicks were 34, not 69.
In August 2026 we moved the English-language site of a B2B supply-chain consultancy off WordPress and onto a static build on Cloudflare Pages. The old WordPress install had been hacked at some point before we arrived. Nobody at the client had noticed, because the injected pages never appeared in the site's menus. Google had noticed. Three weeks after launch, Google Search Console still listed more than a hundred casino and betting pages under the client's domain, and they were earning a large share of its clicks.
What did the hack leave behind?
The hack left behind 103 injected gambling pages: casino "reviews" and betting-brand landing pages in about ten languages, all hosted under the client's domain. Google Search Console's URL Inspection tool showed them as "Submitted and indexed". In the 28 days after launch they brought 29 of the site's 67 clicks, so almost half of the site's search traffic was spam. The queries behind those clicks were betting brand names such as Pandabet and Picklebet, which have nothing to do with logistics.
Why did the spam survive the migration?
The spam survived the migration because Google had no reason to look at those URLs again. The pages already returned 404 on the new site and on the old host. Googlebot had last crawled them on 4 August, before the cutover, so Google's index still held the hacked versions. A 404 only takes a page out of Google once Googlebot requests the URL and sees the 404. On a small site, low-value URLs can wait weeks or months for that visit.
How did we find every legacy URL?
Finding every legacy URL took three sources, because no single one is complete. Google Search Console's performance data gave us the URLs that had earned impressions. The Wayback Machine's CDX API gave us URLs that existed at some point, including ones Google never ranked. Ahrefs gave us the URLs other sites link to, which are the ones that carry link equity. Merged and deduplicated, the list split into three groups: spam, real pages that had moved, and leftovers from the WordPress theme's demo content, such as a shop and a "wagyu burger" service page.
We left the spam and the demo pages as 404s on purpose. Neither had an equivalent on the new site, and a page that is gone should say so.
How were the redirects set up and checked?
The redirects were set up as 94 exact rules and 2 wildcard rules. The wildcards cover the two sections whose slugs carried over unchanged: everything under /capability/ goes to the matching /services/ page, and everything under /portfolio/ goes to the matching /case-study/ page. Each of the other 94 old URLs points at the current page on the same topic, matched by hand.
We then tested all 134 cases against the live site. Each old URL had to return a 301 to the expected page, and that page had to return a 200. All 134 passed.
Why didn't the first set of redirects work?
The first set of redirects didn't work because of a missing trailing slash. We had declared them as page aliases in each page's frontmatter. The static site generator wrote those alias sources without a trailing slash, and Cloudflare Pages matches redirect sources exactly. Every real legacy URL ended in a slash, so none of the aliases ever matched. The pages rendered correctly and the build passed, so the only way to catch it was to request the old URLs on the live site. We moved every rule into the site's central redirects config and ran the 134 checks again.
How do you make Google recrawl dead URLs?
To make Google recrawl dead URLs, list them somewhere Googlebot reads. On 18 September we published a temporary sitemap of 237 URLs, the spam plus the legacy pages, and submitted it through the Google Search Console API. A sitemap normally lists pages you want indexed, so this one is a deliberate stretch with a short life. It exists only to get Googlebot to request each URL once and see the 404 or the 301.
Google fetched the recrawl sitemap on 10 October. After that, URL Inspection reported the spam URLs as "Not found (404)" and the legacy URLs as "Page with redirect".
What happened to the spam traffic?
The spam traffic fell steadily once Google started recrawling. Spam clicks were 24 between 1 and 15 September, 20 between 16 and 30 September, and 3 between 1 and 11 October.
Why should SEO reporting filter out hack spam?
SEO reporting should filter out hack spam because the spam distorts every number the client looks at. We added exclusion patterns for the betting brands and casino terms to the client's SEO dashboard. For the 28 days to 11 October, the site's clicks dropped from 69 to 34 once the spam was excluded, and impressions dropped from 7,877 to 5,045. The top-queries table showed the consultancy's real topics again. The dashboard states what it excludes, so nobody mistakes the lower number for a traffic loss.
The patterns needed care. We tested them against both language versions of the site before switching them on. They matched nothing on the Polish site, and they left real queries alone: queries containing "better" still count, and "slot", an ordinary warehousing term, is only excluded as part of "video slots".
What is left to do?
One step is left: deleting the recrawl sitemap. Once the Search Console Pages report shows the spam URLs gone, the sitemap comes out of the site and out of Search Console's sitemap list. If any spam lingers, the next tools are the Search Console Removals tool and a check of the Security Issues and Manual Actions reports.
Why isn't a migration finished at launch?
A migration isn't finished at launch because Google's copy of the old site outlives the old server, including everything a hacker ever added to it. The redirect map protects the pages you meant to keep. The recrawl sitemap and the reporting filter deal with the pages you didn't know were there.
If you're planning a move off WordPress, or you've already moved and your Search Console numbers look odd, talk to us. We'll check what Google still holds for your domain.
References
- Google Search Central. Build and submit a sitemap. developers.google.com
- Google Search Central. How HTTP status codes and network errors affect Google Search. developers.google.com
- Internet Archive. Wayback CDX Server API. github.com/internetarchive/wayback












