Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Malware redirect sending mobile or ad visitors elsewhere: fix it

OPS-140High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A malicious redirect is code an attacker has planted on your site or server. It checks who is visiting and, for certain visitors, sends them to another address. Typical targets are mobile devices, visitors with a gclid or other ad parameter in the URL, or people who come from Google or social networks.

The hack hides from the owner on purpose. If you open the site on your laptop by typing the address, it loads normally. The redirect only fires for the visitors who are most valuable to you.

Common hiding places: .htaccess or nginx rules, JavaScript added to theme files or the database, tampered plugins, tags in your tag manager, and index.php or wp-config.php edits.

Why it costs you leads or sales

Every redirected visitor is a lost lead, and if they came from a paid ad you still pay for the click. Because the hack targets mobile and ad traffic, your conversion rate drops while analytics may show only a small change in total traffic. Search engines and browsers may also flag the site, which hurts trust and rankings.

Where an ad visitor is lost
  1. Ad clickVisitor on a phone clicks your ad
  2. Landing URLInjected code detects mobile and ad parameter
  3. Spam pageVisitor is sent to a scam or unrelated site
  4. Form or checkoutNever reached

The redirect fires before the page content or form loads.

Conversions by deviceExample numbers
Conversions by device (example)Desktop before: 3 %; Mobile before: 2.4 %; Desktop after: 3 %; Mobile after: 0.2 %01232.430.2Desktop beforeMobile beforeDesktop afterMobile after%

Example: desktop converts as usual while mobile ad traffic collapses after the hack.

How to check if your site has it

Test as the targeted visitor
  1. Open your landing page on a real phone

    Use mobile data, not your office Wi-Fi, in a private tab. Add a fake ad parameter such as ?gclid=test123&utm_source=google.

  2. Emulate mobile on desktop

    In Chrome DevTools, toggle the device toolbar and pick a phone. Open the Network tab, tick Preserve log, and reload to see which request returns a 301 or 302 and where it points.

  3. Test with a referrer

    Search for your brand on Google on a phone and click your result. Some hacks only trigger when the referrer is a search engine.

  4. Check the response from the command line

    Run the curl command below and look for Location headers.

  5. Ask customers and your ad team

    Reports of 'your site took me to a casino' or a sudden drop in mobile conversions are strong signals.

Request as a mobile visitor from Google with an ad parameterbash
curl -I -L -A "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1" -e "https://www.google.com/" "https://example.com/landing?gclid=test123"

How to fix it

Clean the infection
  1. Find the redirect source

    Search server config and files for rules or scripts that redirect by user agent, referrer or query string. Look for RewriteCond %{HTTP_USER_AGENT}, HTTP_REFERER, window.location, eval(, atob( and base64_decode.

  2. Restore clean files

    Replace core files, themes and plugins with fresh copies from the official source or your last known clean backup. Delete plugins and themes you do not use.

  3. Clean the database

    Check posts, widgets, theme options and custom code fields for injected script tags.

  4. Remove unknown users and backdoors

    Delete admin accounts you do not recognise and look for recently modified or oddly named PHP files, especially in uploads folders. Attackers often leave a way back in.

  5. Rotate every credential

    Change hosting, FTP/SFTP, database, CMS admin, and API keys. Regenerate the secret keys and salts in wp-config.php if you use WordPress.

  6. Patch the entry point

    Update the CMS, themes and plugins, and remove the vulnerable component that let the attacker in.

Where to look by platform
  1. Reinstall core

    Go to Dashboard > Updates > Re-install version, or replace wp-admin and wp-includes by hand. Check the root .htaccess, wp-config.php and the active theme's header.php and functions.php.

  2. Review users and plugins

    Under Users, remove unknown administrators. Under Plugins, delete anything unfamiliar or abandoned and reinstall the rest from wordpress.org.

Example of a malicious rule to remove (do not add this)htaccess
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (android|iphone|mobile) [NC]
RewriteCond %{QUERY_STRING} gclid [NC]
RewriteRule ^(.*)$ http://spam.example/landing [R=302,L]
Mobile ad visitor

Hacked

  • Desktop looks normal
  • Phone with gclid is redirected
  • Ad spend wasted

Cleaned

  • Same page on every device
  • Ad parameters kept
  • Form and checkout reachable

How to confirm it's fixed

Confirmation checks
  • Phone on mobile data loads the landing page with ?gclid=test123
  • curl with a mobile user agent and Google referrer returns 200 with no unexpected Location header
  • Search results click-through on a phone lands on your page
  • Submit a test lead and confirm it reaches your inbox and CRM
  • No unknown admin users, plugins or scripts remain
  • Google Search Console shows no security issues

How to prevent it happening again

Hardening
  • Keep CMS, themes and plugins updated and delete unused ones
  • Use unique strong passwords and two-factor authentication for hosting, CMS and tag manager
  • Limit admin accounts and review them monthly
  • Keep off-site backups you can restore quickly
  • Use a web application firewall or host-level malware scanning
  • Turn on file change alerts
  • Test your key landing pages on mobile with ad parameters after every deploy

How FunnelGuard handles this

FunnelGuard detects this only partly. It runs a redirects check on your journey URLs: when the robot visitor loads a step and ends up somewhere unexpected, the run fails, a second region re-checks it, and you get one alert with a screenshot and a likely cause.

What it does not do: it is not a malware scanner, it does not inspect your server files, database or users, and it cannot see redirects that only fire for conditions the robot does not match, such as a specific real phone, a real ad click or a particular referrer. It never clicks real ads.

Cover the rest by hand: run the phone and curl tests above after changes and on a regular schedule, watch mobile conversion rate by device in your analytics, check Search Console's Security issues report, and use a server-side malware scanner and file integrity alerts.

Questions people ask

Why does my website redirect to spam only on mobile?

Malicious code often checks the visitor's user agent and redirects phones only, so site owners testing on desktop see nothing wrong. Look for redirect rules in .htaccess or server config, injected JavaScript in theme files or the database, and unknown tags in your tag manager.

Why are my Google Ads visitors being sent to another site?

Some hacks trigger only when the URL contains an ad parameter like gclid or when the referrer is Google. Test your landing page with ?gclid=test123 on a phone and check the Network tab for 301 or 302 redirects.

How do I find a redirect hack in my website files?

Search for rewrite rules using HTTP_USER_AGENT or HTTP_REFERER, and for JavaScript using window.location, eval, atob or base64_decode. Also check recently modified files, theme header files, wp-config.php and database content.

Is a redirect hack the same as a Google Safe Browsing warning?

No. A redirect hack is the infection itself, while a Safe Browsing warning is a possible consequence once Google detects it. You can have the redirect for weeks before any warning appears.

How do I stop my site being hacked again after cleaning it?

Close the entry point by updating or removing vulnerable plugins and themes, rotate all passwords and keys, remove rogue admin users and backdoor files, and enable two-factor authentication. Keep off-site backups and run regular scans.

Can FunnelGuard detect a malware redirect?

Partly. It runs a redirects check on your journey URLs and alerts you if a step ends up somewhere unexpected. It is not a malware scanner and cannot catch redirects that only trigger for real phones, real ad clicks or specific referrers.

Will cleaning the site stop ad money being wasted?

Once visitors reach your page again, yes. Confirm with a phone test using an ad parameter, then check that ads point to working URLs and that mobile conversions recover in your analytics.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: Redirects matcher on journey URLs.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.