deindexwebsites.com

Hacked and spam-injected sites

Hacked Site With Spam Pages in Google: Cleanup and Deindexing

Deindexing a hacked site is the last step, not the first. If you remove spam URLs while the vulnerability is still open, new ones appear. Clean first, then clear the index.

By the deindexwebsites.com editorial team · Updated

What hacked content looks like

Google's spam policies define hacked content as content added to a site without the owner's permission, usually through security vulnerabilities. It describes four forms:

  • Code injection: malicious JavaScript added to existing pages or iframes
  • Page injection: spammy or malicious new pages, often for manipulation or phishing
  • Content injection: hidden text or links, or cloaking, hard for owners and users to spot
  • Redirects: some users sent to spammy pages depending on referrer, user agent or device

In search, you may see unfamiliar page titles under your domain, pages in other languages, product or gambling terms you never published, or your own pages with different titles in results than in the browser.

The right order

  1. Contain. Take the site offline or to a maintenance state if there is active harm, such as malware or phishing.
  2. Find the entry point. Outdated plugins or themes, weak credentials, exposed admin, compromised hosting or FTP accounts. Rotate every credential: hosting, database, CMS, SFTP, API keys.
  3. Clean. Restore from a known clean backup if you have one, or remove injected files, database entries, rogue admin users, cron jobs and modified rewrite rules.
  4. Patch. Update everything, remove unused plugins, and add a web application firewall or access controls where suitable.
  5. Then clear the index. Return 404 or 410 for the spam URLs, remove them from sitemaps, and request removals.
  6. Check Search Console for security issues and manual actions, and file a review if one exists. Details in hacked site recovery and reviews.

Seeing what Google sees

Spam is often cloaked: shown to Googlebot but not to you. Use URL Inspection with the live test, view the rendered HTML, and compare with your browser. Also test with a different user agent and referrer, since some injections only trigger for search visitors. Check site:yourdomain.com combined with spam keywords, e.g. adding terms you never published, to surface injected URLs.

Handling the spam URLs

SituationAction
Injected URLs that you removedServe 404 or 410
Pattern-based spam (thousands of URLs under a path)Block the path at the server with a 410, then prefix removal if it is under a stable path
Spam URLs at random pathsReturn 410 for unknown routes; fix the CMS to return real 404s
Legitimate pages with injected contentClean the content; no removal needed, just recrawl
Spam subdomainsRemove DNS records or configure the default host to return 404; see subdomains

Serve proper errors, not 200 pages with "not found" text. A CMS that returns 200 for every unknown URL makes infinite spam URLs look valid.

Removals and recrawl

  • File prefix removals for spam directories.
  • Remove spam URLs from sitemaps, and submit a clean sitemap of real pages to prompt recrawl.
  • Do not block spam paths in robots.txt before Google sees the 404/410, for the reasons in robots.txt mistakes.
  • Be patient. Google has no stated deadline, and large injections can linger for weeks.

Search Console Help notes that the Removals tool is not a substitute for fixing hacked content. It only hides results temporarily.

Preventing reinfection

  • Updates automated for CMS, plugins and themes
  • Unused plugins, themes and accounts deleted
  • Strong unique credentials and multi-factor authentication
  • File integrity monitoring or regular diff against a clean copy
  • Admin areas restricted by IP or authentication
  • Backups stored off the server and tested
  • Search Console alerts delivered to a monitored inbox
  • Server logs retained for investigation

Spam on a site you do not host

If a third party's site shows spam that mentions you, or a hacked site links to yours, those are different problems. For content on other sites use official reporting flows.

Example: a Japanese-keyword style injection

Site owners often describe discovering thousands of unfamiliar product pages under their domain in a pattern like /shop/random-name-123.html. The pattern matters more than the language. A typical response: identify the generating script, remove it and the rewrite rules that routed those URLs, rotate credentials, then make the web server return 410 for the injected path pattern and file a prefix removal if the spam sits under one stable path. If spam URLs use query strings or random roots, rely on a correct 404 for unknown routes and let Google's recrawl clear them, while watching logs for new entries.

What to preserve for investigation

  • A copy of injected files and database rows before deleting
  • Server access and error logs covering the first suspicious date
  • The list of spam URLs Google has indexed
  • A list of modified or new files in the web root

Communicating with users and customers

If the compromise exposed visitors to malware or phishing, say so plainly on your site or by email once it is safe to do so. If personal data was involved, legal notification duties may apply depending on where you and your users are; seek qualified advice. Search cleanup is the visible part of an incident, not the whole of it.

Frequently asked questions

Can I just deindex the whole hacked site?

You can, but it harms your legitimate pages. Clean and clear only the spam unless the site is being retired.

Why do spam pages keep coming back?

The entry point is still open, or a backdoor remains. Re-scan files and database, and rotate credentials.

Does the Removals tool fix a hack?

No. It hides results temporarily and does not remove the cause.

Will cleaning remove warnings immediately?

No. Google must recheck the site; follow the review process in the recovery guide.

Official sources

Keep reading