Email: hello@attors.comServing businesses and agencies in the US, UK & Europe Rated 5.0 on Google
Attors Technologies
Attors Technologies

Menu

Project enquiries

hello@attors.comChat on WhatsAppMon–Sat, 04:00–21:00 UTC. We reply within one business day.
0% · Why you can't see the redirect but your visitors can
Performance & Reliability

WordPress Site Redirecting to Spam? How to Find and Fix It

If your WordPress site redirects visitors to spam, gambling or pharmacy pages, treat it as a hack until proven otherwise. The redirect often shows only to phones or to visitors arriving from Google, so your own checks may look fine.

Serious man reading documents and checking a laptop screen in an office

The short answer

  • A WordPress site that sends some visitors to spam or gambling pages is almost always hacked. The redirect often shows only to people who arrive from Google or use a phone, so you can look at your own site and see nothing wrong.
  • The usual hiding places are the .htaccess file, injected script in the theme or database, a plugin you didn’t install, and an admin account you didn’t create.
  • Take a full backup first, change every password, then compare files against clean copies. Cleaning only the redirect leaves the way in open, and the redirect comes back.
  • Most single-site cleanups cost between $199 and $499 with us; the same-day option starts from $349.
  • After cleanup, check Search Console for security issues and manual actions, because a hack can cost you search visibility even after the redirect is gone.

If your WordPress site redirects visitors to spam, gambling, pharmacy or “you’ve won” pages, treat it as a hack until proven otherwise. Hackers often make the redirect conditional, so it fires only for visitors coming from Google, for phones, or for people who are not logged in. That is why the site can look fine to you and still be sending your customers elsewhere.

This guide is for owners and marketing managers who have had a customer say “your website sent me somewhere strange” and need to know what to check, what to leave to an expert and what a fix should cost. It covers the checks in the order we’d run them, why the redirect keeps returning, and what to do about Google afterward. For the wider emergency steps, read our guide on what to do in the first hour after a hack.

Why you can’t see the redirect but your visitors can

A malicious redirect is written to avoid the one person most likely to notice it: you. Hacked-site redirects are commonly written to depend on the visitor’s referrer, device or browser, which is why the same page can behave differently for different people. The typical conditions look like this:

What visitors reportWhat it usually meansHow to test it safely
Redirected only after clicking a Google resultThe redirect checks where the visitor came fromSearch for your own page on Google and click through, instead of typing the address
Redirected only on a phoneThe redirect checks the device typeOpen the page on a phone using mobile data, not your office Wi-Fi
Redirected only when logged outLogged-in admins are skipped on purposeUse a private window with no WordPress login
Redirected once, then fineThe script sets a cookie after the first runClear cookies, or use a fresh private window
Whole site replaced by a spam pageCore settings or the main redirect rules were changedCheck Settings, then General, for the WordPress and Site addresses

Also open Google Search Console and look at the Security issues and Manual actions reports. Google often flags a hacked site there before the owner notices. If you see a hacked-content warning, the problem is confirmed, and you’ll need a review request after the cleanup.

What to do in the first 30 minutes

Move quickly, but don’t start deleting things. Evidence and a clean way back matter more than speed in the first half hour.

  1. Take a full backup of the site as it is now, files and database, and store it away from the web server. You may need it to find the way in.
  2. Change passwords for every WordPress admin, the hosting account, the database, SFTP or SSH and the email address tied to the site. Do the hosting account first.
  3. Check the user list under Users. Any administrator you don’t recognize is a sign of a hack; note it before removing it.
  4. Tell your host. Many hosts can scan the account and show which files changed recently.
  5. Put the site in maintenance mode if customers are being sent to harmful pages, so nobody else is redirected while you work.

Don’t restore an old backup and call it finished. The hole that let the attacker in is still there, and an old backup may already contain the infection. The WordPress.org guide to a hacked site makes the same point: find the cause, not just the symptom.

Where spam redirects hide in a WordPress site

Redirects live in a handful of places. Checking them in this order finds most of them.

The .htaccess file

On Apache hosting, this file in the site’s root folder controls redirects. A clean WordPress file contains one block between the lines “BEGIN WordPress” and “END WordPress”, plus any rules you added deliberately. Anything unfamiliar outside that block, especially rules that mention search engines, mobile devices or unfamiliar domains, deserves attention.

Theme and plugin files

Malicious script is often added to a theme’s header, footer or functions file, or tucked into a plugin that looks harmless. A plugin that isn’t in your dashboard but exists in the plugins folder is suspicious. So is a plugin or theme that was “nulled” (a pirated copy of a paid product), since these often ship with a backdoor.

The database

Redirect code can sit inside posts, widgets, theme options or site settings, so cleaning files alone won’t remove it. Look for script added to widget areas and for changes to the site address settings. Database cleaning is where DIY attempts go wrong, because removing the wrong row can break the site.

Uploads and hidden files

The uploads folder should hold images and documents, not code. Script files in there, or files with odd names that look like core files, are red flags. They’re often the backdoor that brings the redirect back after a cleanup.

Admin users and scheduled tasks

A new administrator account is a common way back in. Scheduled tasks that re-create deleted files do the same job quietly. If a cleaned site is reinfected within hours, one of these is usually responsible.

From our projects: We start every cleanup by scanning the site and quoting a fixed price before any work begins. A cleanup replaces core files with clean copies, removes malicious code from plugins, uploads and the database, hardens the site and closes the way in, then ends with a written report. Standard cleanups carry a free re-clean within 30 days.

Why the redirect keeps coming back

Reinfection has three common causes, and each one needs a different fix.

CauseSignThe fix
A backdoor was missedThe redirect returns within hours or daysFind and remove every hidden file and rogue admin; replace core files from official copies
The entry point is still openCleaned site is hacked again weeks laterUpdate or remove the vulnerable plugin or theme; strengthen passwords and access
Stolen passwords still workNew admin accounts appear againReset hosting, database, SFTP and WordPress passwords; review who has access

Prevention is mostly boring maintenance: keep core, plugins and themes updated, delete what you don’t use, use unique passwords with two-factor sign-in, and keep tested backups away from the web server. The WordPress hardening guide lists the settings worth checking. If nobody on your team does this monthly, a WordPress care plan covers updates and backups for $49, $99 or $199 a month depending on the plan.

Clean it yourself or hire a specialist?

You can clean a simple infection yourself if you have a recent clean backup, comfortable access to your files and a quiet afternoon. For most business sites, the risk of leaving a backdoor outweighs the saving. Use this as a guide:

Your situationBetter route
Hobby site, clean backup from before the hack, comfortable with files and the databaseDIY, following the WordPress.org guide
Business site, redirect came back once alreadySpecialist cleanup
Online store or customer data on the siteSpecialist cleanup, and think about your notification duties
Site is down, losing sales or flagged by GoogleSame-day specialist cleanup
No backup, or you can’t tell when the hack happenedSpecialist cleanup

Our WordPress malware removal service starts at $199, with an emergency same-day option from $349. Most cleanups cost between $199 and $499 depending on how big the infection is, and you approve a fixed quote first. For the full cost picture, including lost sales, see our guide to what a hack costs to fix.

Clean up your search results after the fix

Getting rid of the redirect is half the job. Google may have indexed spam pages on your domain, and visitors may have seen a warning. Work through these after the cleanup:

  • Check Search Console’s Security issues report and fix anything listed.
  • If you have a manual action for hacked content, fix the cause and submit a review request from the Manual actions report. Explain what you cleaned and how you closed the way in.
  • Search Google for your domain plus words like casino or pills, to spot spam pages that were indexed.
  • Remove spam URLs by returning a proper error for them, then resubmit your sitemap.
  • Watch Search Console for a few weeks for new security warnings.

If the hack damaged content or pages were deleted, our guide on restoring a website from the Wayback Machine explains what can be recovered. Preventing the next one belongs in your website maintenance plan.

WordPress spam redirect questions

Why is my WordPress site redirecting to spam only on mobile?

Because the malicious code checks the visitor’s device and only redirects phones. This keeps the hack hidden from the owner, who usually checks on a desktop. Look in the .htaccess file and theme files for unfamiliar conditions, and test on a phone using mobile data.

Why does my site only redirect when people click from Google?

The code checks where the visitor came from and redirects only search traffic. It does this so you can type the address, see nothing wrong and not suspect a hack. Click through from a Google result in a private window to reproduce it.

Is a redirect to spam always a hack?

Almost always when the destination is spam, gambling or pharmacy pages you never set up. Harmless causes, such as an old redirect plugin or a changed domain setting, send people to your own pages or another page you chose. A redirect to a site you don’t recognize is a hack.

Will restoring a backup remove the redirect?

Sometimes, but it often returns. The backup may already be infected, and restoring it doesn’t close the vulnerability that let the attacker in. Restore only from a backup dated before the hack, then update everything and change all passwords.

Can a redirect hack hurt my Google rankings?

Yes. Google can flag the site, show warnings or apply a manual action for hacked content, and spam pages added to your domain can appear in results. Once the cleanup is done and any manual action is reviewed, visibility usually recovers, though the timing varies.

How much does it cost to remove a WordPress redirect hack?

With us, most single-site cleanups cost between $199 and $499. The cleanup starts from $199, and a same-day option starts from $349. You get a fixed quote before work starts, and a free re-clean within 30 days on the standard cleanup.

Should I change passwords before or after cleaning the site?

Change them first, starting with the hosting account, then the database, SFTP and WordPress admins. If the attacker still has a working password, they can undo your cleanup. Change them again after the cleanup if you used any shared device.

How do I stop my WordPress site being hacked again?

Keep core, plugins and themes updated, delete the ones you don’t use, avoid pirated plugins, use unique passwords with two-factor sign-in and keep tested backups off the server. Most reinfections trace back to one outdated plugin.

Get a hacked site cleaned and closed

Attors Technologies is a web development agency that cleans, repairs and maintains WordPress sites for businesses in the US, UK and Europe. Send us the site address and what visitors are seeing. We scan it, quote a fixed price and clean it, then close the way in and send a written report.

Get your hacked WordPress site cleaned

Written byAttors Development TeamWordPress, e-commerce and custom development

The Attors Development Team builds and maintains WordPress, WooCommerce, Shopify and custom Next.js websites for businesses and agencies in the US, UK and Europe, from themes and plugins to speed, security, hacked-site recovery and migrations.

Performance & Reliability

Website Hacked? What to Do in the First Hour

A calm, step-by-step plan for the first hour after a website hack: contain it, protect customers, clean the site and recover your search visibility.