Website Hacked With Gambling or Spam Pages? How to Detect and Clean It

Most website owners find out their site has been hacked when a customer calls to say “your website opened a betting page”. Often the owner never sees anything wrong: the hacked pages are hidden from them and shown only to Google or to visitors from certain countries. This guide explains how that works, how to check your own website in 15 minutes, and how to clean it up. It is based on what we found on our own website this year.

What happened to our website

In 2026, while auditing stemstech.net, we opened Google Search Console and saw something we had not expected. In the previous three months our homepage had received more than 126,000 clicks from Google, almost all of them from Turkey, for searches for a Turkish betting brand. Google had also indexed spam pages with titles like “ALERT! I’m hacked…” under our domain.

None of this was visible when we opened the website ourselves. The old site had been compromised with cloaked spam: hidden code that showed gambling content to Google and redirected certain visitors, while showing the normal site to everyone else. The site had since been rebuilt on a clean installation, but Google still remembered the spam pages, and our real, local search visibility was tiny by comparison.

How this kind of hack works

  • An outdated plugin, theme or weak password lets attackers upload a small script.
  • The script creates spam pages (gambling, pharma, fake stores) or changes existing pages.
  • It uses cloaking: spam is shown only to Googlebot, to mobile visitors, or to visitors arriving from Google, so the owner sees nothing unusual.
  • Your domain’s trust is used to rank the spam. Your real pages lose visibility, and Google may show a “This site may be hacked” warning.

How to check your website in 15 minutes

  1. Search Google for site:yourdomain.com and scroll through the results. Look for titles in other languages, betting or pharma words, or pages you never created.
  2. Open Google Search Console → Performance. Sort queries by clicks and look at the Countries tab. Traffic from countries you don’t serve, or searches unrelated to your business, is a strong warning sign.
  3. Search Console → Security & Manual Actions. Both “Manual actions” and “Security issues” should say No issues detected.
  4. Search Console → URL Inspection → Test live URL → View tested page → HTML. This shows exactly what Google’s crawler receives. Search it for words like “casino”, “bet” or “viagra”.
  5. Indexing → Pages. A sudden jump in “Not found (404)” or “Crawled, not indexed” URLs you don’t recognise often means spam pages were created and later removed.

Is it the website, or your computer?

If the site redirects to an advertising page only on your own computer, the cause may be a browser extension or adware, not the website. Test it in a private (incognito) window and on your phone using mobile data. If the website looks normal there, clean up your browser extensions and run a malware scan on your computer. If it redirects everywhere, the website itself is infected.

How to clean a hacked WordPress website

  1. Take a full backup first (files and database), so you have evidence and a fallback.
  2. Change every password: WordPress admins, hosting/cPanel, FTP and the database user. Remove admin users you don’t recognise.
  3. Verify the core files. WordPress publishes official checksums for every version. Any core file that doesn’t match, or any extra PHP file in wp-admin or wp-includes, should be replaced with a fresh copy. Do the same for plugins from WordPress.org.
  4. Look for PHP files in wp-content/uploads. That folder should contain images and documents, never PHP.
  5. Check .htaccess, the active theme and the database for injected redirects, unknown scripts and spam content.
  6. Update everything and delete unused plugins and themes. They are the most common way in.
  7. If the infection is deep or keeps coming back, rebuild on a clean installation and move only the verified content. That is what we did.

Recovering in Google after the clean-up

  • Make spam URLs return 410 Gone, so Google drops them faster than with a normal 404.
  • Redirect (301) your own old pages that had real visitors or links to the closest current page, so their value isn’t lost.
  • Submit a clean XML sitemap containing only real, indexable pages.
  • If Search Console shows a security issue or manual action, fix it and request a review.
  • Watch the Countries and Queries reports for a few weeks. The spam searches should disappear.

How to keep it from happening again

  • Keep WordPress, plugins and themes updated, and remove what you don’t use.
  • Use strong, unique passwords and two-factor login for admins.
  • Run a security plugin with a firewall and scheduled scans.
  • Keep automatic off-site backups.
  • Check Search Console once a month. It’s the earliest warning you’ll get.

Frequently asked questions

Why can’t I see the spam when I open my website?

Because the hack hides it from you. Cloaked spam is usually shown only to Google’s crawler, to mobile visitors or to visitors from a search engine. Use Search Console’s URL Inspection live test to see what Google sees.

Will my rankings come back after cleaning?

Usually, once Google re-crawls the site and the spam URLs are gone. It typically takes a few weeks. Pages that had real rankings recover faster when they stay at the same URL.

Is deleting the spam pages enough?

No. If the backdoor that created them is still there, they come back. The entry point must be found and closed, and passwords changed.

Need help?

If your website shows signs of a hack, or you’re not sure, we can check it for you and clean it up. See our website security and malware removal service, or contact us for a free first check.

admin
Written by

admin

The STEMSTECH team writes about building websites, apps and software that help businesses grow.

Free consultation

Have an Idea? Let's Build It.

Tell us what you want to build. Our Meerut team will reply with a clear plan, timeline and a transparent quote — usually within one business day. Call or WhatsApp +91 84491 30385.

  • Reply within one business day
  • NDA available on request
  • Fixed-scope or flexible engagement

Your details are confidential. We never share them.

WhatsApp