---
title: "WordPress Malware Redirect: First-Hour Steps for Spam Hacks"
url: https://hostmy.blog/wordpress-malware-redirect-fix/
date: 2026-11-03
modified: 2026-11-03
lang: en
author: "Aditya Sharma"
description: "A WordPress malware redirect often shows only to some visitors. How to confirm it, back up, contain it, find the cause and tell Google, in the first hour."
categories:
  - "WordPress"
image: https://hostmy.blog/wp-content/uploads/2026/10/hmb-card-2671-1024x538.jpg
word_count: 1619
---

# WordPress Malware Redirect: First-Hour Steps for Spam Hacks

A WordPress malware redirect sends your visitors somewhere you did not choose, usually a spam or scam site, and it often does so only for some of them. You may load your own site and see nothing wrong, while a reader who arrives from a search result is bounced away. That is part of what makes it dangerous, and part of why people lose days to it.

This post is for the first hour. It covers how to confirm the problem, what to do before you touch anything, how to contain it, and where to look for the cause. It is built on the [WordPress.org guide to a hacked site](https://wordpress.org/documentation/article/faq-my-site-was-hacked/) and on what Google says about hacked content, and it does not replace a proper cleanup. If you are not sure, or if the site makes money, stop after the containment steps and get help.

![Numbered outline of this post, WordPress Malware Redirect: First-Hour Steps for Spam Hacks: 1 Confirm what you are dealing with; 2 Contain it: lock the doors; 3 Where redirect malware tends to hide; 4 After cleaning: passwords again, and find the way in; 5 Tell Google, once the site is clean; 6 When to stop and call someone.](https://hostmy.blog/wp-content/uploads/2026/10/hmb-diagram-2671.png)The route through this post.

## Confirm what you are dealing with

A redirect hack is often conditional. The malicious code checks who is asking, and only acts for some visitors, such as people arriving from a search engine, people on a phone, or people who are not logged in. The owner, who usually visits directly and is logged in, sees a normal site. So the first job is to look at the site the way a stranger would.

This asks for your homepage with a mobile browser string and a search engine as the referrer, and prints where each hop leads.

`curl -sIL -A "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)" -e https://www.google.com/ https://yourdomain.com/ | grep -iE '^(HTTP|location)'`

You want to see your own address and a 200. A Location header pointing at a domain you do not recognise confirms a redirect. Try it again without the mobile string, and with a post address as well as the homepage. WordPress.org lists signs that point the same way: a site flagged by Google or another provider, and a host that has disabled the site. It also lists readers saying their antivirus is warning them, and behaviour you did not authorise, such as new users.

## Before you touch anything: document and back up

The WordPress.org guide puts documentation first. Write down what you are seeing, the time you noticed it and your timezone, and anything you changed recently, such as a new plugin or a theme edit. It becomes your incident record, and it helps whoever assists you.

Then take a backup of the site as it is now, files and database, even though it is infected. The guide recommends this snapshot before cleaning, because a cleanup can go wrong and you will want something to refer back to. Keep it away from the live site and do not restore it later by accident. If you already have a clean backup from before the infection, find it and note the date, because it may be your fastest route to recovery. [The WordPress backup that did not restore](/wordpress-backup/) explains why testing backups matters long before this day.

## Contain it: lock the doors

| Step | Why | How |
| ---- | --- | --- |
| Tell your host | A hack on shared hosting can affect other sites and the server's mail | Open a support request and describe the symptoms |
| Reset every password | The attacker may still hold a working login | Hosting panel, SFTP, database, WordPress admins |
| Set new secret keys | It logs out anyone still signed in | Replace the keys and salts in wp-config.php |
| Remove unknown users | Attackers create their own administrators | Check the Users screen, or list administrators with wp-cli |
| Scan your own computer | An infected machine can leak your logins | Run a full scan with a second tool if the first finds nothing |

The WordPress.org guide covers each of these, including the warning that the infection often starts on the site owner's own computer, through stolen logins. Do the password changes in order of importance: the hosting account, then SFTP and the database, then WordPress. You will change them again once the site is clean, because the first set may have been exposed again in between.

This lists every administrator on the site, which is where unknown accounts tend to appear.

`wp user list --role=administrator --fields=ID,user_login,user_email,user_registered`

An administrator you do not recognise, registered around the time the trouble began, is a strong sign. Do not delete it yet if you are keeping evidence. Remove its access by changing its role, and note it down. [WordPress user roles: who should get what access](/wordpress-user-roles/) explains why old accounts are the quiet risk.

## Where redirect malware tends to hide

The WordPress.org guide names the places to look first. The .htaccess file is the one it singles out, because it is edited in so many kinds of attack, and it may sit in the root and in other folders as well. The theme files index.php, header.php, footer.php and functions.php are also worth checking, since a change there affects every request. For redirects specifically, two further places are worth a look: the site address settings in the database, and the active plugin list for anything you did not install.

`wp option get siteurl
wp option get home
grep -n -i 'rewritecond\|rewriterule' .htaccess
wp plugin list --status=active --format=table`

The first two should show your own address. In .htaccess, read the rewrite rules and look for conditions that mention search engines, referrers or mobile browsers, and for destinations you do not recognise. The plugin list should contain only plugins you chose. This is a reading exercise, not a certain test, and a clean result on these four does not prove the site is clean.

## Replace, do not repair

The cleanest way to deal with core files is to replace them. WordPress.org advises reinstalling the same version of WordPress your site runs, not an older or newer one, and doing it with SFTP and not the reinstall option in the dashboard. Its reasoning is that the dashboard installer only overwrites existing files, and hacks often add new ones. The wp-admin and wp-includes folders can be replaced safely this way, and the guide suggests being more careful in wp-content, which holds your themes, plugins and uploads.

This checks core files against the official release, and it is the fastest compromise check there is.

`wp core verify-checksums`

Anything it reports as modified or unexpected is a lead. Plugins and themes are handled the same way: reinstall each from its official source rather than editing the infected copy, and delete the ones you no longer use. Then update everything, because the guide notes that older versions are more prone to hacks.

## After cleaning: passwords again, and find the way in

Once you believe the site is clean, change every password a second time. The guide is explicit about this, because the first change happened while the attacker might still have been present. Consider changing the database user's password as well, and update wp-config.php to match.

Then ask how it happened. This is the forensics step, and it is the one people skip. An outdated plugin, a stolen password and a vulnerable theme are the common routes, and if you do not close the hole the site will be infected again. If you do not have the logs or the skills to find out, say so in your incident record, and treat every plugin you cannot account for as suspect. [WordPress security without a security plugin that fights your host](/wordpress-security/) sets out the habits that make the next attempt harder.

## Tell Google, once the site is clean

If Google has flagged the site, the Security Issues report in Search Console is the place to work. Google's help page on it says to expand each issue, follow its steps, and fix the problem throughout the whole site, not just on the sample pages it lists. When everything is fixed, you select Request Review and explain the problem, what you did and the result. Do not submit early, and do not resubmit while a request is pending. Google says premature or repeated requests can slow later reviews, or lead to being marked a repeat offender. It says reviews can take several days or weeks. The page is the [Security issues report help](https://support.google.com/webmasters/answer/9044101).

## What it costs you if you wait

A redirect hack does damage while it is live. Readers are sent to a bad site, browsers and search engines may warn people away, and mail from the server can be blacklisted. The first hour matters because it is the difference between a contained problem and one that spreads. That is also why [what to actually monitor on a WordPress site](/wordpress-monitoring/) includes watching for changes you did not make.

## When to stop and call someone

Stop if you cannot find the cause after the checks above, or if the site comes back infected after you clean it. Stop too if it is a shop or a source of income, or if your host has suspended it. At that point the useful work is forensic, and a second pair of experienced eyes saves days. If you already have a verified backup from before the infection, restoring it is often faster than hunting through files.

Last checked in October 2026 against the WordPress.org hacked-site guide and Google's Security issues report help. Both are updated from time to time, so check the current versions before acting on a detail.

## Where Host My Blog fits

Cleaning up hacked sites is part of what we do on the blogs we look after, and it is why we test restores and watch for changes. This post is the self-help version, and it is meant to get you through the first hour safely. If you would rather hand it over, [our care for bloggers](/for-bloggers/) covers it.

If a reader emailed you tonight to say your site sent them somewhere strange, would you know what to do in the next sixty minutes?