The symptoms
A redirect hack sends some or all visitors away from your WordPress site to spam, fake prize or scam pages. Common signs:
- visitors from Google or mobile get redirected, but you (logged in) do not
- the redirect happens only once per visitor, so it is hard to reproduce
- Google shows "This site may be hacked" — see fixing the Google hacked warning
- unknown admin users or plugins appear
Attackers make redirects conditional precisely so owners do not notice.
Step 1: Contain it
- Put the site into maintenance mode or take it offline if customers are being sent to scams.
- Change every password: WordPress admins, hosting, FTP/SFTP, database and email.
- Take a full backup of the infected site for investigation — do not overwrite your clean backups.
Step 2: Find the malicious code
Redirect code usually hides in a handful of places:
- `.htaccess` — look for
RewriteCondrules checking the referrer or user agent, followed by a redirect to an unknown domain. - `wp-config.php` and theme `functions.php` — look for
eval(,base64_decode(,gzinflate(or long unreadable strings. - The database — search the
wp_optionstable (especiallysiteurlandhome) andwp_postsfor injected<script>tags. - `wp-content/uploads` — PHP files should never be in uploads. Any
.phpfile there is suspicious. - Must-use plugins in
wp-content/mu-plugins, which load silently.
Compare core files against a fresh copy of the same WordPress version. Anything that differs in wp-admin or wp-includes has been tampered with.
Step 3: Clean and rebuild
The safest clean-up is a rebuild: fresh WordPress core, fresh copies of plugins and themes from official sources, and only your content and media brought across after inspection. Remove any plugin you do not recognise or no longer use.
Step 4: Close the way in
Redirect hacks almost always start with one of:
- an outdated or nulled plugin or theme — see WordPress plugin security testing
- a reused or weak admin password — see brute force attacks
- an exposed file such as a backup or
.env— see exposed .env files
Turn on two-factor authentication, remove unused admins, and follow our WordPress hardening guide.
Step 5: Confirm it is gone
Check the site from a private window on mobile data, request a review in Google Search Console, and run a security scan to make sure nothing else is exposed. Our general hacked website recovery guide covers the wider steps, including when to notify the ICO.
A free Yrzo AI scan will flag exposed files and missing protections in about a minute. For a full post-incident check, reports start at £149 — see plans.
Related reading: "This Site May Be Hacked" Warning in Google: How to Remove It · Website Blacklisted? How to Check and Get Removed · Website Defaced? What to Do in the First 24 Hours