Nexura Security
Download Free

100% Free · No credit card required

Back to Blog
Tutorials August 8, 2026 1 Views

WordPress Redirect Hack: How to Find and Remove Malicious Code

nexurasecurity
Nexura Security
Security Researcher
WordPress Redirect Hack: How to Find and Remove Malicious Code

Understanding the WordPress Redirect Hack

The "Redirect Hack" is currently one of the most common and frustrating malware infections hitting WordPress websites. When a visitor tries to access your site, they are abruptly redirected to a malicious page—often a fake tech support scam, an adult site, or a phishing page.

What makes this hack insidious is that it often evades detection by only redirecting users coming from search engines (like Google) or mobile devices, while appearing completely normal to you when you log in as an admin.

Need immediate help?

If your site is currently hacked or showing warnings, our incident response team can help right now.

Fix My Site Now

Where Does the Redirect Code Hide?

Hackers inject redirect scripts into various parts of your WordPress architecture. The most common hiding spots are:

  1. .htaccess File: Hackers modify your server's configuration file to redirect traffic before WordPress even loads.
  2. wp-config.php: Malicious PHP code is placed at the very top of your configuration file.
  3. Theme Files: header.php or footer.php are prime targets for malicious JavaScript injections.
  4. The Database: Injections via vulnerable plugins often place JavaScript payloads directly into the wp_options or wp_posts tables.

How to Fix the Redirect Hack

Step 1: Check your .htaccess file

Access your site via FTP or your host's File Manager. Look at the `.htaccess` file in your root directory. A normal WordPress `.htaccess` looks like this:

Sponsored Pro Version

Upgrade to Nexura Pro

Get enterprise-grade protection. Block zero-day exploits, advanced malware, and brute-force attacks instantly.

Get 50% Off Now

LIMITED TIME LAUNCH OFFER

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If you see strange, complex rules redirecting to random URLs, delete them and restore the default rules.

Step 2: Automate the Cleanup with Nexura

Manually checking the database and every PHP file is tedious. The best approach is to use Nexura Security.

  • Run a full Deep Malware Scan. Nexura's AST engine is specifically designed to find obfuscated JavaScript and PHP redirects that traditional signature scanners miss.
  • Remove the flagged files or restore them to their original state using Nexura's Core Restore feature.

Step 3: Patch the Vulnerability

The hacker got in somehow. In 95% of cases, it was through an outdated plugin. Update all plugins immediately and delete any plugins you are no longer using.

Preventing Future Redirect Hacks

The easiest way to stop redirect hacks is to block the initial payload. Ensure the Nexura Web Application Firewall (WAF) is enabled. It will intercept the malicious requests trying to inject the redirect code and block the attacker's IP address instantly.

Share this article:
Nexura Security Team

Nexura Security Research Team

WordPress Security Experts

The Nexura Research Team continuously monitors the WordPress ecosystem for emerging threats, zero-day vulnerabilities, and malware trends. Our mission is to provide actionable intelligence to keep your websites secure, fast, and resilient against modern cyber attacks.

nexurasecurity

Written by Nexura Security

Did this article help? If you need professional assistance implementing these security measures or recovering from a hack, we are just a click away.

Comments (0)

No comments yet. Be the first to share your thoughts!

Leave a Comment

You must be logged in to post a comment.

Log In

Secure Your WordPress Site Today

Get enterprise-grade protection with Nexura Security. Setup takes less than 60 seconds.

Download Free Plugin

Stay Ahead of Hackers

Join our growing community of site owners who receive our weekly WordPress security alerts, vulnerability reports, and hardening tips.

SSL Secured
GDPR Compliant
WP.org Verified
OWASP Protected
Secure Your Infrastructure Today