WordPress SecurityHacked Site Fix

How to Fix URL Injection (SEO Spam) on WordPress

Spam pages you never created showing up in Google? Here is how to confirm the hack, clean it from your server, lock your site down and get the spam URLs out of Google Search.

By Wilson ShresthaUpdated November 20268 min read9 steps
On this page · 0/9 steps done
  1. What is URL injection?
  2. Signs of infection
  3. How to fix it (9 steps)
  4. Prevention
  5. FAQ

⚡ Key takeaways

  • The fix: back up, scan and clean infected files and the database, remove unknown users, change every password and replace nulled themes and plugins.
  • Then clean Google: make the spam URLs return 410, remove them in Search Console and request a review.
  • Cloudflare alone is not a fix. It blocks bot traffic but does not remove the malicious code from your server.

The basicsWhat is URL injection?

URL injection (also called SEO spam, spam link injection or the Japanese keyword hack) happens when an attacker gets access to your website and makes it generate thousands of new spam pages. The pages usually sell counterfeit goods or link to gambling, adult or scam sites. Many of them redirect real visitors to a third-party site, while showing different content to Googlebot so the pages get indexed. This trick is called cloaking.

The attacker's goal is to borrow your domain's trust in Google to rank their spam.

Example of URL injection: spam pages and bot traffic on a hacked website
A site: search showing injected Japanese spam pages on a hacked domain. Click to zoom.

Common causes

Nulled or cracked themes and plugins"Free" copies of premium software very often contain hidden backdoors.
Outdated softwareOld versions of WordPress core, themes or plugins with known vulnerabilities.
Weak or reused passwordsFor WordPress admin, cPanel, FTP or the database.
Insecure hostingWrong file permissions, or an infected site on the same cPanel account spreading to yours.

DiagnosisSigns your site has URL injection

01Unknown pages on GoogleSearching site:yourdomain.com shows pages you never published, often with strange titles or foreign-language text.
02Indexed pages jumpThe Search Console Pages report suddenly shows thousands of new indexed or "Crawled – currently not indexed" URLs.
03Strange keywordsThe Performance report shows clicks and impressions for keywords unrelated to your site.
04Security warningSecurity & Manual Actions → Security issues shows "Hacked: content injection" or "Hacked: URL injection".
05Bot traffic floodAnalytics shows a very high bounce rate, fake page views and lots of 404 hits.
06Redirects and ad limitsVisitors from Google get redirected to another site, or AdSense limits ads on your site.

Step by stepHow to fix URL injection

Work through the steps in order and tick each one off as you finish it. Your progress is saved in this browser, so you can come back later.

1

Back up the site before you change anything

Easy

Take a full backup of your files and database from cPanel (or your host's backup tool). Even an infected backup is useful: if a clean-up step breaks something you can restore it, and you can compare the infected files later.

!

Don't overwrite your older backups. A backup from before the infection may be the fastest way to recover.

2

Scan the site for malware

Easy

Install a security scanner such as Wordfence, MalCare or Sucuri Security and run a full scan. These tools compare your WordPress core, theme and plugin files with the official versions and flag modified files, backdoors and suspicious code. Many hosts also have a malware scanner (for example Imunify360) in cPanel.

3

Remove nulled software and reinstall clean copies

Easy
  • Delete every nulled or cracked theme and plugin. Buy the real version or replace it with a free alternative from WordPress.org.
  • Delete themes and plugins you don't use.
  • Reinstall WordPress core from Dashboard → Updates → Re-install version. This replaces the core files without touching your content.
  • Update all remaining themes and plugins to their latest versions.
4

Clean the infected files manually

Medium

Scanners miss things, so check these places yourself in cPanel File Manager or over FTP:

  • .htaccess in the site root: look for redirect or rewrite rules you didn't add.
  • wp-config.php and index.php: look for long encoded strings such as eval(, base64_decode( or gzinflate(.
  • wp-content/uploads/: this folder should hold images and documents, not .php files. Any PHP file in it is very likely a backdoor.
  • wp-content/mu-plugins/: "must-use" plugins load automatically and are a common hiding place.
  • Unknown folders or files with random names, or files modified recently when you made no changes.
  • cPanel → Cron Jobs: delete any cron job you don't recognise, because it can reinfect the site.
✓

Tip: sort files by "Last modified" in File Manager. Files changed on the same date as the first spam pages are the best place to start.

5

Clean the database

Advanced

Some injections live in the database rather than in files. Open phpMyAdmin (or use your scanner's database scan) and check:

  • wp_posts: spam posts or pages, often saved with a strange post type or status.
  • wp_options: check that siteurl and home point to your own domain, and look for options containing scripts or links to unknown domains.
  • wp_users: unknown administrator accounts. You can also check this under Users in the dashboard.
!

Be careful: a wrong database edit can break your site. If you aren't comfortable with phpMyAdmin, ask your host or a malware removal service to do this step.

6

Lock the site down

Medium
  • Delete unknown admin users, then change the passwords for every WordPress user, cPanel, FTP/SFTP and the database. Put the new database password in wp-config.php.
  • Replace the security keys and salts in wp-config.php. This logs out everyone, including the attacker.
  • Turn on two-factor authentication for admin accounts.
  • Set safe file permissions: usually 644 for files and 755 for folders.
7

Block bot traffic with Cloudflare

Easy

After a URL injection, bots often keep hitting the spam URLs for weeks. Putting your site behind Cloudflare's free plan helps:

  1. Create a Cloudflare account, add your domain and switch your nameservers to the ones Cloudflare gives you.
  2. During a heavy bot flood, turn on Under Attack Mode. Every visitor gets a short browser check, which stops most bots.
  3. Once traffic is back to normal, turn Under Attack Mode off (it slows down real visitors too) and use Bot Fight Mode and WAF rules instead.
Cloudflare Under Attack Mode setting to block bot traffic
The Under Attack Mode switch in the Cloudflare dashboard. Click to zoom.
i

Important: Cloudflare only filters traffic before it reaches your server. If the malicious files are still there, the spam pages still exist and Google can still crawl them. Finish steps 2–6 first.

8

Make the spam URLs return 410 (Gone)

Medium

Once the site is clean, the spam URLs should return a 404 or, better, a 410 Gone status, which tells Google they are deleted for good. If the spam URLs share a pattern (for example a fake folder), one rule in .htaccess covers all of them. Replace spam-folder with the pattern you actually see:

.htaccess
RewriteEngine On
RewriteRule ^spam-folder/ - [G,L]
✓

Check the pattern so it can't match a real page. A plugin such as Redirection or Rank Math can also send a 410. Don't redirect spam URLs to your homepage, because Google can treat that as a soft 404.

9

Clean up in Google Search Console

Easy
  • Check owners and sitemaps: in Settings → Users and permissions, remove any owner you don't recognise. In Sitemaps, delete any sitemap you didn't submit, then resubmit your real one.
  • Remove spam URLs: go to Indexing → Removals → New request. You can remove a single URL or every URL with a given prefix. This hides them from search results temporarily (about six months) while Google recrawls and drops them.
  • Request a review: if Security issues lists a problem, click Request review and explain what you cleaned and how you secured the site.
  • Use URL Inspection on a few spam URLs to confirm they now return 404 or 410.

If AdSense was limited, open the Policy center in your AdSense account and request a review once Google confirms the site is clean.

Stay safeHow to prevent URL injection

✕No nulled softwareNever install cracked themes or plugins.
↻Stay updatedKeep core, themes and plugins current; auto-update plugins you trust.
🔑Strong loginsUse unique passwords and two-factor authentication.
🛡Firewall and scansRun a security plugin with scheduled scans.
💾Off-site backupsKeep regular backups so you can restore a clean copy fast.
📈Weekly checksLook at Search Console for new pages, odd keywords and warnings.

QuestionsFrequently asked questions

Does Cloudflare fix URL injection?

No. Cloudflare reduces bot traffic and protects against attacks, but it doesn't delete the malicious code on your server. You have to clean the files and database yourself or with a malware removal service.

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

The Removals tool hides them within about a day. Dropping them from the index for good takes longer, usually a few weeks to a few months depending on how many URLs there are and how often Google crawls your site. Returning 410 instead of 404 usually helps.

Will my rankings recover after URL injection?

In most cases, yes. Once the hack is removed and Google has recrawled the site, rankings usually return gradually. Recovery is slower if Google issued a manual action or security warning, so request a review as soon as the site is clean.

Will AdSense come back after the clean-up?

Usually, if AdSense limited ads because of the hack. After the site is clean, check the AdSense Policy center and request a review.

Should I just restore a backup?

Restoring a backup from before the infection is often the fastest fix, but you still have to close the hole the attacker used (nulled software, an outdated plugin or a stolen password). Otherwise the site will be reinfected.

Still seeing spam pages?

Describe what you see in Search Console and I'll help you track it down.

Ask in the comments →

Once your site is clean, improve its rankings with our guides to on-page SEO techniques and keyword research.

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
free fire hack diamond
free fire hack diamond
5 years ago

Wow, marvelous weblog structure! How long have you ever been running a blog for?

you make blogging glance easy. The full glance of
your site is wonderful, as well as the content material visit free fire hack diamond !