Website Redirecting to a Gambling Site? How to Fix It
Visitors from Google land on judi or slot sites but your site looks fine? That's cloaked redirect malware. How to confirm, find and remove it.
Short answer: if customers say your website sends them to an online gambling ("judi", "slot") or similar page, but it looks normal when you open it, your site has conditional redirect malware. The malicious code checks who is visiting: a phone, someone arriving from Google, or a first-time IP address. It redirects only those visitors and shows you the normal page. To fix it, confirm the redirect the way a customer would, find the code (usually in .htaccess, an injected script or the database), remove it, rotate every credential and close the entry point.
Why you can't see it
Google's documentation on the cloaked keywords and links hack explains the pattern: attackers serve different content depending on the visitor, so search engines and targeted users see spam while the site owner sees a normal site (web.dev). Redirect variants commonly check:
- the user agent, so only phones are redirected;
- the referrer, so only visitors who clicked a Google result are redirected;
- a cookie or IP address, so each visitor is redirected only once, which makes it hard to reproduce;
- whether you are logged in, so administrators are never redirected.
Step 1: Reproduce it the way a customer would
- Log out of WordPress, or use a private browser window.
- On a phone using mobile data (not your office Wi-Fi), search Google for your business name and tap your result.
- Try a second phone or a friend's phone if the first does not redirect. The malware may redirect each IP only once.
- In Search Console, use the URL Inspection tool and View tested page. It shows the HTML Google receives, which may include the injected code (Google).
Write down the URL you were sent to. Searching your files and database for that domain is the fastest way to find the code.
Step 2: Find the redirect code
Check these places in this order:
| Where | What to look for |
|---|---|
.htaccess in the root and in subfolders | RewriteCond %{HTTP_REFERER} or %{HTTP_USER_AGENT} rules pointing to an outside domain |
wp-config.php, index.php, theme functions.php, header.php | eval(, base64_decode(, gzinflate(, long encoded strings, header('Location: |
The database (wp_options, wp_posts, widget options) | <script tags with unfamiliar domains, or siteurl/home changed |
wp-content/uploads/ | Any .php file, which should never be there |
wp-content/mu-plugins/ | "Must-use" plugins you did not install, which load automatically and do not show in the normal plugin list |
| Hosting cron jobs | Tasks that download code from outside URLs, which recreate the malware after you delete it |
Step 3: Remove it properly
Deleting the redirect line alone is not enough. A backdoor usually puts it back. Follow the full sequence in how to remove malware from a WordPress site: snapshot, rotate every credential including the WordPress salts, reinstall core, plugins and themes from clean sources, clear the uploads folder of PHP files, then patch the way in.
Step 4: Clean up search results
Redirect hacks often come with spam pages. Search site:yourdomain.my for gambling or foreign-language titles. If you find them, read the Japanese keyword hack guide. Make sure removed spam URLs return 404 or 410, check Search Console for owners you don't recognise and any Security issues, and request a review once the site is clean (Google's hacked-site guide). Google's spam policies treat hacked content and sneaky redirects as violations, so an unresolved hack can cost you rankings as well as visitors.
Why this matters in Malaysia
Redirecting your customers to an illegal gambling site damages trust in your brand, and for clinics, education providers, financial advisers or law firms it can raise questions from regulators and professional bodies. Fix it the same day you find out, and tell customers through your usual channels if they may have been affected.
Want it handled? JagaWeb's Emergency Recovery is quoted per incident and covers containment, malware removal, credential rotation and a written report. See hacked website repair, or run the free website check first. Bahasa Malaysia: Laman web kena hack: apa perlu buat. All plans and fixed prices are on the pricing page.
FAQ
Why does the redirect only happen on phones? The malware reads the visitor's user agent and targets mobile users, who are less likely to inspect the URL and less likely to be the site owner at a desk.
I removed the code and it came back. Why? A backdoor or a scheduled task is reinstalling it. Look for PHP files in uploads, unknown mu-plugins and cron jobs, and rotate every password and the WordPress salts.
Will this hurt my Google rankings? It can. Google may label your result "This site may be hacked" or take manual action for hacked content until it is cleaned up and reviewed.
Ready to verify who owns your website?
Replace uncertainty with a decision-ready ownership and access report. The fixed Ownership & Access Review is RM1,500 before SST and includes a 30-day action plan.