Technical SEO

How to Remove Hacked Spam Pages From Google: My Own Recovery

My own site was hacked and filled with casino spam pages in several languages. This is exactly how I cleaned it, what I'd do differently, and the one Search Console tool that can quietly block your future pages.

A clean website protected by a shield while hacked casino spam pages break apart around it

To remove hacked spam pages from Google, clean the site and close the entry point first, make every spam URL return 404 or 410, then use Search Console's Removals tool to hide the worst URLs temporarily while Google recrawls them. Request indexing on a few spam URLs to speed up recrawling, check that no old server or cache still serves the hacked content, and monitor the Pages report until the spam is gone.

I know this process from the inside, because it happened to my own site. In 2026, my WordPress site sheikhsadikur.com was injected with casino spam pages in Russian, Czech, Polish and other languages, promoting gambling brands. Google indexed them. At the worst point, Search Console showed around 120 indexed URLs, almost all of them spam. This is the full recovery, including the mistakes and surprises.

How to tell your site has been hacked with spam

Spam injection is designed to be invisible to the site owner. Common signs:

  • Strange results for site:yourdomain.com: pages in foreign languages, gambling or pharmaceutical topics, or URLs you never created.
  • Search Console Pages report showing a jump in indexed pages you don't recognize.
  • Performance report queries in languages or topics unrelated to your business.
  • Security issues or manual action notices in Search Console.
  • The site behaves differently for Googlebot than for you. Some hacks show spam only to search engines (cloaking), so your browser looks normal.
  • New admin users, unknown files in uploads folders, or modified core files.

In my case, the spam URLs had slugs like long phrases about casino bonuses and free spins, in several languages. The site itself also started showing WordPress critical errors.

Step 1: stop the bleeding

Before touching Google, make sure the hack can't continue:

  1. Take a backup of the current state for investigation.
  2. Change every password: hosting, cPanel or hosting panel, FTP, database, CMS admin users, email.
  3. Remove unknown admin users and check user roles.
  4. Update or remove outdated plugins, themes and the CMS core. Abandoned plugins are the most common entry point.
  5. Scan for malware: modified core files, PHP files in upload folders, suspicious .htaccess rules and injected database content.

If you skip this and go straight to removing URLs, the attacker simply creates new ones.

Step 2: decide whether to clean or rebuild

There are two ways forward:

  • Clean the existing site: find and remove every malicious file and database entry, patch the entry point and harden the install.
  • Rebuild clean: export the genuine content, set up a fresh install or a different platform, and leave the infected installation behind.

I chose to rebuild. My site was mostly a portfolio and service site, so I rebuilt it as a static HTML site on new hosting, with no PHP and no database to inject into. That removed the attack surface entirely. I still cleaned malware from both the old and new hosting accounts, because leaving infected files on any server you control is asking for trouble.

For larger sites with lots of dynamic content, a careful clean-up and hardening is usually more practical than a rebuild.

Step 3: make every spam URL return 410 or 404

Google drops pages from its index when it recrawls them and finds they no longer exist. The status code you return matters:

Spam pages dropping through a removed-page trapdoor on a conveyor while clean pages continue
  • 404 Not Found: the page doesn't exist.
  • 410 Gone: the page existed and has been removed permanently.

Google treats both as signals to drop the page; 410 is a slightly more explicit statement that the content is gone for good. For spam URLs, I return 410.

On my static site, I used .htaccess rules so that:

  • Any request for a path that isn't a real file or folder returns 410 Gone.
  • Old WordPress paths like /wp-admin/, /wp-content/ and /wp-includes/ return 410.
  • PHP files are blocked from running entirely.
  • A handful of genuine old pages are 301 redirected to their new equivalents, so real links aren't lost.

Two cautions:

  • Don't redirect spam URLs to your homepage. Google may treat that as a soft 404, and it can carry spam signals to your homepage. Let them die with 410 or 404.
  • Make sure real pages still return 200. A catch-all 410 rule means every new page must be a real file or folder. I learned to build every new section, including this blog, as real folders with an index file for exactly that reason.

Step 4: use Search Console removals carefully

The Removals tool in Search Console hides URLs from Google Search for about six months. It doesn't delete them from the index; it hides them while Google recrawls and drops them naturally.

There are two modes:

  • Remove this URL only: hides a single URL.
  • Remove all URLs with this prefix: hides every URL that starts with the given path.

Because my spam URLs were scattered, I used 35 prefix removals on November 6 and 7, 2026, covering short prefixes like /a, /b, /k, /p and /st that the spam slugs started with.

This worked: the spam disappeared from search results quickly. But it came with a trap I want every site owner to know about.

The prefix trap

A prefix removal hides every URL that starts with that prefix, including new, legitimate pages. With /b removed, any page starting with /b, including /blog/, would be hidden from Google for the next six months. With /a removed, so would /about/.

That's why the article you're reading lives under /insights/ rather than /blog/, and why my case studies live under /success-stories/ rather than /case-studies/ (the /ca prefix was removed). Before launching any new section, I check the path against my list of active removals.

Once the spam URLs show as "URL is not on Google" in URL Inspection, the removal requests can be cancelled, freeing those prefixes again.

Step 5: speed up recrawling

Google drops a 410 URL only after it recrawls it. Spam URLs on a hacked site are often crawled rarely, so this can take a long time. Ways to speed it up:

  • Request indexing on spam URLs through URL Inspection. It sounds backwards, but it prompts Google to recrawl, see the 410 and drop the page. There's a daily quota, so prioritize the URLs still showing in the indexed list.
  • Keep the site's sitemap clean, listing only genuine pages, so Google's crawling focuses on real content.
  • Make sure the 410 responses are fast and consistent.

Step 6: check every copy of your site

This was the most surprising part of my recovery. After rebuilding and cleaning, I still saw WordPress critical errors on my own domain. The cause was DNS: some resolvers, including the one my own computer used, still pointed to the old hosting server, which was serving the old broken site.

What to check:

  • DNS records point to the new server, and old records are removed.
  • Your own browser and device aren't using a cached DNS result. Testing from a different network or with a public DNS resolver helps.
  • The old hosting account is either cleaned and serving the new site, or shut down. I temporarily uploaded the clean site to the old server too, so anyone still resolving to it would see the clean version.
  • Server-side caches (LiteSpeed, plugin caches, CDN caches) are purged, so they don't keep serving old hacked pages.

Step 7: monitor until it's gone

Recovery isn't one event. I watch:

  • Search Console Pages report, especially the indexed count and the list of indexed URLs.
  • URL Inspection on remaining spam URLs.
  • Performance report for spam queries disappearing.
  • Security issues report.
  • Backlink profile, because spam pages often attract spam links pointing at them. See the toxic backlinks guide.

What the numbers looked like

For my site, the indexed URL count in Search Console fell from around 120 in August to 7 by November 13, 2026. Of those seven, one was my genuine homepage and six were old spam URLs. Every one of the six returned 410 when I tested it; Google simply hadn't recrawled them since July and August. All six were also covered by active prefix removals, so none appeared in search results.

Why this matters for AI search too

A hack isn't only a Google problem. AI answer engines crawl the web too, and spam pages on your domain can end up associated with your brand. While spam pages are live, your site's topic signals are diluted, and pages about casino bonuses on a consultant's domain undermine the trust that generative engine optimization depends on.

After cleaning up, I paid extra attention to entity consistency: one clear description of who I am and what I do, repeated on the rebuilt site, its structured data and every profile. That helps search engines and AI systems re-establish what the domain is genuinely about.

Recovery checklist

  • [ ] Backup taken, passwords changed, unknown users removed
  • [ ] Entry point patched: CMS, plugins and themes updated or removed
  • [ ] Malware removed from every server and account, including old hosting
  • [ ] Spam URLs return 410 or 404, genuine old URLs 301 to new pages
  • [ ] Removals submitted for the worst spam, with a note of every prefix used
  • [ ] DNS, server caches and CDN caches checked and purged
  • [ ] Clean sitemap submitted in Google Search Console and Bing Webmaster Tools
  • [ ] Indexed count, spam URLs and security report checked weekly
  • [ ] Removals cancelled once spam URLs show as not on Google

What I'd do differently

  • Keep CMS, plugins and themes updated from day one. Outdated software is the most common entry point for spam injection, and it's the cheapest thing to prevent.
  • Set up Search Console alerts and check them weekly. I'd have caught the spam earlier.
  • Use narrower removals where possible. Prefix removals are powerful but block future pages; listing the exact spam paths would have caused fewer side effects, at the cost of more requests.
  • Plan new URLs around the removals before cancelling them, so nothing important launches into a hidden prefix.

Common mistakes in hack recovery

  • Removing URLs before cleaning the site, so new spam appears.
  • Redirecting spam URLs to the homepage.
  • Disavowing everything in a panic. Review spam links properly first.
  • Forgetting the old server, staging copies or caches.
  • Assuming the problem is solved because site: search looks clean, while removals are only hiding what's still indexed.

If you're dealing with something similar, a technical SEO audit that includes security checks is the right starting point. Pages stuck after cleanup sometimes show up as crawled, currently not indexed, which is a different problem with different fixes.

If you're in the middle of this right now

Take a breath. Hacked spam is common, and sites recover from it. Work through the steps in order: secure the site, make spam URLs return 410, hide the worst ones with removals, check every server and cache, then monitor weekly. Keep a written log of what you did and when. It will save you hours when you need to check whether something worked.

Frequently asked questions

How long does it take for hacked spam pages to disappear from Google?

It depends on how often Google recrawls the spam URLs. Once they return 404 or 410, each URL drops after its next crawl, which can take days for active pages and months for rarely crawled ones. The Removals tool hides them from search for about six months while that happens.

Should I use 404 or 410 for hacked spam URLs?

Either works. Google treats both as signals to drop the page. A 410 Gone status states more explicitly that the content was removed permanently, so I use 410 for spam URLs. Don't redirect them to your homepage, which can be treated as a soft 404.

Does the Removals tool delete pages from Google's index?

No. It hides URLs from search results for about six months. The pages are only dropped from the index when Google recrawls them and finds they're gone or blocked by noindex. Use removals to hide spam quickly, and 404 or 410 responses to remove it permanently.

Can a prefix removal block my new pages?

Yes. A prefix removal hides every URL that starts with that path, including legitimate pages you publish later. Check your active removals before launching a new section, choose paths outside removed prefixes, or cancel the removal once the spam is confirmed gone.

Will a hack hurt my rankings permanently?

Usually not, if you clean it thoroughly and the spam is removed. Rankings typically recover as Google recrawls the clean site. Leaving spam online for a long time, or getting a manual action, makes recovery slower, which is why speed matters.

Want results like these for your site?

Send your website and goal. I reply within one business day (Dhaka time, GMT+6).

WhatsApp