You run a site:yourdomain.com search and see hundreds of pages you never published — Japanese text, fake designer-goods shops, casino links. Your WordPress site has URL injection, also known as SEO spam or the Japanese keyword hack.
An attacker has got in and made your site generate thousands of spam pages. The pages usually redirect real visitors to a scam site while showing different content to Googlebot — a trick called cloaking — so the spam gets indexed on the back of your domain's trust. Here is how to spot it, clean it, and get Google to drop the spam URLs.
How to tell you are infected
- A
site:search shows pages you never wrote, often with strange titles or foreign-language text. - The Search Console Pages report suddenly shows thousands of new indexed URLs, and the Performance report shows clicks for keywords that have nothing to do with your site.
- Security & Manual Actions in Search Console flags "Hacked: content injection" or "Hacked: URL injection".
- Analytics shows a flood of bot traffic, fake page views, and 404 hits, or visitors from Google get redirected elsewhere.
The usual entry points are nulled themes and plugins, outdated core or plugins with known vulnerabilities, weak or reused passwords, and insecure hosting.
The 9-step fix
1. Back up first. Take a full backup of files and database from cPanel or your host's backup tool before you change anything. Do not overwrite older backups — a copy from before the infection may be the fastest way to recover.
2. Scan the site. Run a full scan with Wordfence, MalCare, or Sucuri Security. These compare core, theme, and plugin files against the official versions and flag modified files and backdoors. Many hosts also ship a scanner such as Imunify360 in cPanel.
3. Remove nulled software. Delete every cracked theme and plugin, buy the real version or replace it with a free alternative from WordPress.org, and delete themes and plugins you do not use. Reinstall WordPress core from Dashboard → Updates → Re-install version, then update everything that remains.
4. Check files by hand. Scanners miss things. In File Manager or over FTP, look at .htaccess for rewrite rules you did not add, wp-config.php and index.php for long encoded strings such as eval(, base64_decode(, or gzinflate(, and wp-content/uploads/ — that folder should hold images, not .php files. Also check wp-content/mu-plugins/ and delete any cron job in cPanel you do not recognise. Sorting files by "Last modified" helps: files changed on the same date as the first spam pages are the best place to start.
5. Clean the database. In phpMyAdmin, check wp_posts for spam posts saved under a strange post type or status, wp_options to confirm siteurl and home point at your own domain, and wp_users for unknown administrator accounts. Be careful here — a wrong database edit can break your site, so ask your host if you are unsure.
6. Lock the site down. Delete unknown admin users, change every password (WordPress, cPanel, FTP/SFTP, database), replace the security keys and salts in wp-config.php so everyone is logged out, turn on two-factor authentication, and set file permissions to 644 for files and 755 for folders.
7. Block the bot traffic. Bots keep hitting the spam URLs for weeks. Putting the site behind Cloudflare's free plan helps: turn on Under Attack Mode during a heavy flood, then switch it off and use Bot Fight Mode and WAF rules instead. Important: Cloudflare only filters traffic. It does not remove the malicious code, so finish steps 2–6 first.
8. Make the spam URLs return 410 Gone. Once the site is clean, a 410 tells Google the pages are deleted for good. If the spam URLs share a pattern, one .htaccess rule covers them all — replace spam-folder with the pattern you actually see, and check it cannot match a real page:
RewriteEngine On RewriteRule ^spam-folder/ - [G,L] Do not redirect spam URLs to your homepage; Google can treat that as a soft 404.
9. Clean up in Search Console. Remove any owner you do not recognise, delete sitemaps you did not submit and resubmit your real one, then use Indexing → Removals to hide the spam URLs while Google recrawls. If Security issues lists a problem, click Request review and explain what you cleaned. Use URL Inspection on a few spam URLs to confirm they now return 404 or 410. If AdSense limited ads, request a review in the AdSense Policy center once Google confirms the site is clean.
Staying clean afterwards
No nulled software, keep core, themes, and plugins updated, use unique passwords with two-factor authentication, run a security plugin with scheduled scans, keep off-site backups, and check Search Console weekly for new pages, odd keywords, and warnings. Restoring a pre-infection backup is often the fastest fix, but it only works if you also close the hole the attacker used — otherwise the site is reinfected.
The full step-by-step version of this guide, with screenshots, is on Wilson's site: How to Fix URL Injection (SEO Spam) on WordPress: 9 Steps

