Black FridayCyber Monday 2026
14Days
15Hrs
22Mins
44Secs
Flat20% OFF

Our biggest sale of the year20% off the first payment on all maintenance plans. Code BF2026

Grab the deal
WordPress

WordPress Redirecting to Spam Sites: First Steps for a Redirect Hack

If your site sends visitors to spam pages, act in order: contain, back up, check access and files, then clean and prevent. These are the first steps.

wpallsolution 5 min read

A WordPress redirect hack happens when attackers change your site so that visitors, or only some of them, are sent to spam, scam or adult pages. It is stressful, but the first steps are clear: stop the damage, keep a copy, close the ways in, then clean and check. This guide covers those first steps. It is a starting point, not a full clean-up; if you are not comfortable working in files and databases, get help.

Quick answer

Take a backup of the site as it is now, so you keep evidence, and ask your host for help if you can. Change every password: WordPress admins, hosting, FTP or SFTP, and the database. Regenerate the secret keys in wp-config.php so existing logins stop working. Check .htaccess, index.php and your theme files, plus plugins and users, for things you did not add. Replace WordPress core with a clean copy, update everything, and scan again. Redirects may show only to some visitors, so test from a phone and a private window.

How this guide was prepared: it is research-based. We used the official WordPress “My site was hacked” guide listed under Sources, checked on October 23, 2026. We did not inspect your site, and every infection is different. We are a WordPress maintenance and development company, not a dedicated cyber-security firm.

Signs of a redirect hack

  • Visitors land on unrelated sites, often only from search results or on mobile.
  • You see the problem on some devices but not on yours.
  • Search results show strange titles or Google warns visitors.
  • .htaccess or theme files changed when you did not edit them.
  • New administrator users or unknown plugins appear.

The decision tree: where is the redirect coming from?

Flowchart for a WordPress redirect hack: five questions about backups, passwords, files, unknown plugins and users, and final scanning
Five questions guide the first response.
  1. Have you backed up the current state? If not, do it before cleaning (Step 1).
  2. Are all passwords changed? If not, change every access point (Step 2).
  3. Do .htaccess or core files look changed? Compare and restore (Step 3).
  4. Are there unknown plugins, users or scripts? Remove and check the database (Step 4).
  5. Is the scan clean? If not, get expert help (Step 5).

5 first steps

Step 1: Contain and back up

Write down what you see and when it started. Take a full backup of files and the database for evidence, and label it infected so it is never restored by mistake. If a clean backup from before the problem exists, note its date. Consider putting the site in maintenance mode while you work, or ask your host to help isolate it.

Step 2: Change every access point

Change passwords for all WordPress users, especially administrators, then your hosting account, FTP or SFTP users and the database user. Update wp-config.php with the new database password and fresh secret keys; changing the keys logs everyone out. Scan the computers that manage the site too, since stolen saved passwords are a common source. See WordPress login security.

Step 3: Check files and core

Look at .htaccess for rules you did not add, and at index.php, header.php, footer.php and functions.php for odd code. The official guide suggests replacing the wp-admin and wp-includes folders with fresh copies from WordPress.org. If you have command-line access, WP-CLI can compare core files to the official checksums with wp core verify-checksums, and plugin files with wp plugin verify-checksums --all. Deleted core files can be restored with wp core download --force --skip-content, but make a backup first, as it overwrites core files.

Step 4: Look for plugins, users and database changes

Remove plugins and themes you do not recognise or no longer use, and reinstall the rest from trusted sources. Delete unknown administrator accounts; see WordPress user roles. Redirect code can also live in the database, for example in site settings or posts, so check the siteurl and home values and search for suspicious script tags. Be careful here, since mistakes can break the site.

Step 5: Update, scan and monitor

Update WordPress, themes and plugins. Run a malware scan and retest from several devices. If Google flagged the site, fix it and request a review in Search Console. Then find the cause, such as an old vulnerable plugin; otherwise the hack returns. Read our PHP2Shell article to see what hidden backdoors can look like, and consider ongoing maintenance.

Version and hosting differences

  • Some hosts scan and restore for you; ask support before starting.
  • Managed hosts may restrict file access, so use their tools.
  • Servers other than Apache use different rule files, not .htaccess.

How to verify the result

  • No redirects from desktop, mobile, a private window or search results.
  • Core and plugin checksums match.
  • No unknown users, plugins or scripts remain.
  • Search Console shows no security issues.

Common mistakes

  • Cleaning before taking a backup.
  • Changing only the WordPress password.
  • Restoring an infected backup.
  • Fixing the symptom and ignoring the cause.

Frequently asked questions

Why do I only see the redirect sometimes?

Attackers often hide it from site owners and show it only to visitors from search or on mobile.

Will changing my password fix it?

Not by itself. Hidden files or accounts may remain and let the attacker back in.

Can a plugin clean it for me?

A scanner helps to find problems, but manual checks are still important and no tool is perfect.

Should I restore a backup?

Only a backup taken before the infection, and then fix the cause and update immediately.

What to do next

If your site is redirecting right now, contact our emergency WordPress fix service. We do not promise a result in advance, because every infection is different. Contact us with what you see.

Sources and official documentation

Keep reading

More guides

Need a hand with this?

Tell us what is happening. We reply with honest next steps.

Talk to us