If Google shows pages from your site in Japanese, or selling pills, replica handbags or casino games -- and you never wrote them -- your site has an SEO spam hack. The spam is often invisible when you visit the site yourself, which is why it can go unnoticed for weeks. This guide explains how to confirm an SEO spam hack (such as the Japanese keyword hack or the pharma hack), find where the spam lives on a WordPress site, clean it up, and get the spam pages out of your sitemap and Google's results.
What an SEO spam hack is
Attackers break into a site -- almost always through an out-of-date plugin, theme or a stolen password -- and use your domain's good reputation to rank their own pages. The main types are:
- Japanese keyword hack. Thousands of auto-generated pages with Japanese text, usually in random folders such as
/ltjmnjp/341.html, linking to shops selling fake brand goods. - Pharma hack. Links and pages for erectile-dysfunction drugs and other pills, often injected into your real pages.
- Gambling, loan and essay spam. The same idea with different products.
The spam usually uses cloaking: it's shown only to Google's crawler, or only to people arriving from a Google search, while you see your normal site when you type the address. Some hacks also add the attacker as an owner of your site in Google Search Console, so they can submit their own sitemaps.
Signs you have SEO spam
- Google results for your domain show foreign-language titles, drug names or products you don't sell.
- Search Console shows a sudden jump in indexed pages, or in pages you don't recognize.
- Your sitemap lists posts or URLs you didn't create.
- Visitors say clicking your site in Google takes them to a shop or scam page.
- Search Console emails you about a "new owner" or "hacked content".
Step 1: Confirm it with a site: search
In Google, search for your domain with the site: operator (replace example.com with your domain):
site:example.com
site:example.com viagra OR cialis OR pharmacy
site:example.com casino OR slot OR replica
Scroll through several pages of results. Look for Japanese or Chinese titles, random-looking folder names, or products that aren't yours. Write down three or four example spam URLs -- you'll use them to test your cleanup later.
Step 2: Check your sitemap and robots.txt
Open your sitemap in a browser. For WordPress it's usually https://example.com/wp-sitemap.xml, or https://example.com/sitemap_index.xml if you use Yoast SEO or Rank Math.
- Open each sub-sitemap (posts, pages, categories). Spam posts inserted into your database show up here with titles you didn't write.
- Look for post types you don't use or recognize.
Then open https://example.com/robots.txt. A Sitemap: line pointing to a file you don't recognize is a strong sign of this hack. In Files > File Manager, look in public_html for extra sitemap files (sitemap1.xml, sitemap.txt, random names ending in .xml) and folders with random names.
Step 3: Check Google Search Console
If you haven't set it up, see How to Add Your Website to Google Search Console and Submit a Sitemap. Then check:
- Settings > Users and permissions. Remove any owner or user you don't know. If an unknown owner was verified with a file or DNS record, delete that verification file from
public_html(named likegoogle1234abcd.html) or the TXT record in Domains > Zone Editor -- otherwise they can verify again. Keep your own verification. - Indexing > Sitemaps. Remove any sitemap you didn't submit.
- Security & Manual Actions > Security issues and Manual actions. Note anything listed, including the sample URLs Google gives.
- URL Inspection. Paste one of your spam URLs and click Test Live URL, then View Tested Page. This shows what Google sees, which exposes cloaking.
Step 4: Contact us and lock the doors
Open a support ticket as soon as you've confirmed the hack. Our server scans for malware automatically, so we can tell you what was found and roughly when it started, which helps you choose a backup. Then change every password connected to the site -- WordPress admins, cPanel, FTP and the database user -- as described in What to Do If Your WordPress Site Is Hacked.
If you'd rather have it cleaned for you, our dedicated service handles exactly this. See Website Infected with Malware? How to Get It Cleaned.
Step 5: Find and remove the spam
Option A: Restore a clean backup
If the spam started within the last two weeks, restoring files and database from a JetBackup 5 backup taken before it started is the most reliable fix. Then update everything straight away, or the same hole gets used again. The steps are in the hacked-WordPress guide linked above. If the hack is older than your oldest backup, clean it by hand below or get a professional cleanup.
Option B: Clean it by hand
SEO spam hides in a few predictable places. Check them all -- missing one means the spam comes back.
1. Spam posts and users in the database. In WordPress, check Posts, Pages and Users, sorted by date. Delete anything you didn't create, and any administrator you don't recognize. With SSH (Advanced > Terminal in cPanel) and WP-CLI, you can list the newest content quickly. --skip-plugins --skip-themes stops any infected plugin code from running while you look:
cd ~/public_html
wp --skip-plugins --skip-themes post list --post_type=any --post_status=any --orderby=date --order=DESC --fields=ID,post_type,post_status,post_date,post_title --posts_per_page=30
wp --skip-plugins --skip-themes user list --role=administrator --fields=ID,user_login,user_email,user_registered
2. Damaged WordPress core and plugin files. WP-CLI can compare your files with the official copies from WordPress.org:
wp --skip-plugins --skip-themes core verify-checksums
wp --skip-plugins --skip-themes plugin verify-checksums --all
Any file reported as modified, or "should not exist", needs attention. For core, wp core download --force --skip-content replaces the WordPress files without touching wp-content. Reinstall plugins from their official source. Premium plugins can't be checked this way -- download a fresh copy from the vendor.
3. Extra files and folders. In File Manager, look for folders with random names in public_html, and sort by Last Modified to spot recent changes. PHP files inside wp-content/uploads are almost always malicious. In Terminal:
find ~/public_html/wp-content/uploads -name "*.php"
find ~/public_html -name "*.php" -mtime -30 -printf '%TY-%Tm-%Td %p\n' | sort
grep -rlE "eval\(base64_decode|gzinflate\(base64_decode|str_rot13\(" ~/public_html --include=*.php
Not every hit is malware -- some plugins legitimately use these functions -- but random file names, recent dates and heavily scrambled code are red flags. You can also run Virus Scanner from cPanel (type "virus" in the cPanel search bar).
4. .htaccess cloaking rules. Open public_html/.htaccess (see How to Show Hidden Files (.htaccess) in cPanel File Manager). Look for rules mentioning googlebot, HTTP_USER_AGENT, HTTP_REFERER with google, or rewrites like RewriteRule ^google(.*)\.html$. A standard WordPress block looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Keep blocks you recognize, such as the LSCACHE section added by LiteSpeed Cache, your HTTPS redirect, or WP Toolkit's security rules. Check for extra .htaccess files in subfolders too.
Step 6: Check it's really clean
Test the spam URLs you wrote down. They should now return 404 (Not Found) or 410 (Gone):
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/ltjmnjp/341.html
Then test for cloaking by pretending to be Google, and by arriving from a Google search:
curl -s -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://example.com/ | grep -iE "viagra|casino|<title>"
curl -s -e "https://www.google.com/" -o /dev/null -w "%{http_code} %{redirect_url}\n" https://example.com/
The first should show only your real title. The second should show 200 and no redirect. If our server's security shows a check page to the fake Googlebot request, use Search Console's URL Inspection > Test Live URL instead -- it's the real Googlebot.
Step 7: Clean up Google's results
- Let spam URLs return 404 or 410. That's how Google learns they're gone. Don't redirect them to your home page.
- Don't block spam URLs in robots.txt. If Google can't crawl them, it can't see they're gone, and they can linger in results.
- Resubmit your real sitemap in Indexing > Sitemaps once it only lists your real pages.
- For a whole spam folder, you can make it return 410 Gone quickly with a line in
.htaccessabove the WordPress block (use your real folder name):RewriteEngine On RewriteRule ^ltjmnjp/ - [G] - Urgent or embarrassing results can be hidden temporarily with Search Console's Removals tool while Google recrawls. It hides them for about six months; it doesn't remove them from the index by itself.
- If Google listed a security issue, click Request Review and explain what you removed and how you closed the hole.
Expect the spam results to fade over several weeks. Large Japanese keyword hacks with thousands of pages can take a few months to disappear fully. Check with a site: search every week or two.
Prevent it happening again
- Keep WordPress, plugins and themes updated, with automatic security updates on -- How to Update WordPress, Plugins and Themes.
- Watch WP Toolkit's vulnerability warnings and remove plugins you don't use.
- Apply WP Toolkit security hardening -- How to Secure WordPress with WP Toolkit Security Hardening.
- Use unique passwords and two-factor authentication, and never install "nulled" premium plugins.
- Do a
site:search on your own domain once a month.
Common questions
Why can't I see the spam when I visit my site?
Cloaking. The spam is shown only to search engines or visitors coming from Google. Use URL Inspection or the curl tests above to see what Google sees.
Should I redirect the spam URLs to my home page?
No. Redirects tell Google the content moved, and it may treat them as "soft 404s" and keep them around longer. A plain 404 or 410 is the fastest way out.
Will this hurt my rankings?
It can while the spam is live, especially if Google shows a "This site may be hacked" label. Once the site is clean and Google has recrawled it, rankings usually recover.
The spam came back after I cleaned it
Something was missed -- usually a backdoor file, a hidden admin user, or the vulnerable plugin that let them in. Restore from an older clean backup if you have one, or get a professional cleanup.
Related guides
- What to Do If Your WordPress Site Is Hacked
- Website Infected with Malware? How to Get It Cleaned
- How to Add Your Website to Google Search Console and Submit a Sitemap
- How to Restore Your Whole Account to an Earlier Date (JetBackup 5)
- How to Secure WordPress with WP Toolkit Security Hardening
Still stuck? Open a support ticket and the Instant Access Internet Services team will help.
