Signs of Redirect Malware and How to Diagnose It
Attackers using 2026 techniques usually do not show their scripts to every visitor; instead, they target only people arriving from specific referrers. For example, an administrator who opens the site directly sees nothing wrong, while a user coming from Google search results is automatically redirected to a malicious page. This delays the moment the administrator notices the attack and keeps the malware active longer.
The first step in diagnosis is to check how your site looks on different devices and browsers. Mobile devices are attackers’ favorite targets because mobile users tend to pay less attention to the address bar. If you inspect your site’s source code and see JavaScript blocks made up of unreadable characters (base64-encoded), that is a clear sign of an attack.
To confirm an infection, reviewing server logs and file modification dates is a technical must. Files changed without your knowledge in the last 24–48 hours point to where the attacker got in. In particular, .php files inside folders such as wp-content/uploads, which should normally contain only media files, are proof of a backdoor on the system.
- Check the “Security Issues” report in Google Search Console.
- Test your site from a different IP address and in an Incognito (private) window.
- Run an external scan with free online scanners such as Sucuri SiteCheck.
Detecting User-Agent Manipulation
- Open the “Network” tab in your browser’s developer tools and follow the redirect chain.
- Access your site as a bot (Googlebot) to see whether the source code changes.
- Analyze the server response headers with cURL commands to catch 301 or 302 redirects.
| Threat Category | Most Affected File | Detection Difficulty | Prevalence in 2026 | Urgency of Response |
|---|---|---|---|---|
| JavaScript Injection | header.php / footer.php | Low | %35 | High |
| Server-Side Redirect | .htaccess | Medium | %28 | Critical |
| Database Manipulation | wp_options | High | %22 | Critical |
| PHP Backdoor | wp-includes directory | Very high | %10 | Medium |
| Fake Admin Account | wp_users | Medium | %5 | High |
Manually Checking .htaccess and wp-config.php
On WordPress sites running on Apache, the .htaccess file is the command center for redirect rules. With a single line added to this file, attackers can send all of your traffic to servers they control. They often hide this code at the very bottom or top of the file behind hundreds of blank lines, so always scroll all the way to the end when you open it.
The wp-config.php file is the most critical configuration file, since it holds your database credentials. Malicious code injected into it runs on every page load and can trigger the redirect even before the database connection is established. By current standards, functions such as eval or base64_decode added to this file are easily caught by modern firewalls, but manual cleanup is always the most reliable solution.
Comparing your files with the original WordPress core files is the fastest way to spot foreign code. If the file contains lines starting with RewriteCond %{HTTP_USER_AGENT} that point to a URL you do not recognize, delete them immediately. After the cleanup, setting these files’ permissions (CHMOD) to read-only, 444 or 400, prevents the attacker from modifying the same file again.
- Download the .htaccess file from your root directory to your computer via FTP or File Manager.
- Remove every suspicious line other than the default WordPress blocks.
- Delete any foreign code blocks that appear right after the
<?phptag at the top of wp-config.php.
Cleaning Hidden Redirect Code from the Database (SQL)
Cleaning the file system is sometimes not enough, because redirect commands may have been injected directly into database tables. In particular, attackers change the siteurl and home values in the wp_options table to hijack the site’s main entry point. If these values point to an address other than your domain, you can lose access to the site entirely.
In addition, small <script> tags planted inside content in the wp_posts table can trigger redirects only when certain posts are read. These attacks are often called “SEO spam” and can plant ad links across thousands of your pages. You need to scan all tables with phpMyAdmin or a similar database tool and search for malicious strings (for example ‘eval’, ‘unescape’, ‘String.fromCharCode’).
The most important rule for a database cleanup is to take a full SQL backup first. A single row deleted by mistake can make your site stop loading entirely. SQL queries used for database security support complex regular expressions (regex), which makes this cleanup more precise and professional.
- Open the
wp_optionstable in phpMyAdmin and verify the site and home URLs. - Use “UPDATE” queries on the
wp_poststable to remove injected scripts in bulk. - Permanently remove unknown or suspicious admin accounts from the
wp_userstable.
Automated Scanning with 5 Popular WordPress Security Plugins
Manual cleanup is time-consuming and error-prone, and this is where professional security plugins come in. Backed by databases of thousands of known malware signatures, these tools scan your site in depth and find files you might miss. Beyond file scanning, these plugins can also monitor behavioral changes on the server side.
Automated scanners compare WordPress core files with their original versions and report any changes instantly. They can also find backdoors hidden inside your theme or plugins and remove them with one click. With their firewall (WAF) features, they also block new attack attempts in real time after the cleanup.
When choosing a plugin, look for solutions that provide effective protection without consuming too many of your site’s resources. Some plugins scan in the cloud to reduce the load on your server, while others protect directly at the server (endpoint) level. Choosing the one that fits your needs will maximize your site’s security while preserving its performance.
- Wordfence Security: Provides real-time threat defense and in-depth file integrity scanning.
- Sucuri Security: Specializes in website auditing, malware scanning and security hardening.
- MalCare: Scans in the cloud without slowing down your site and offers automatic cleanup.
- iThemes Security: Adds more than 30 layers of security, such as login restrictions and database backups.
- All In One WP Security & Firewall: Makes complex security settings easy with its user-friendly interface.
Source: WordPress.org security plugins
The Clean Install and File Replacement Method
If the infection has spread deep into your site and plugins cannot clean it, the most radical and safest solution is to reset the core files. This means replacing all software files with clean copies without touching your site’s database. That way, no script the attacker hid among your files has a chance to survive.
The critical point with this method is the wp-content folder, because it holds your themes, plugins and uploaded images. Attackers usually hide inside this folder, especially in the uploads directory. That is why you need to delete not only the files in the root directory but also every plugin inside wp-content, then download them again from official sources (WordPress.org or wherever you bought them).
After the clean install, it is recommended to recreate your wp-config.php file manually and enter your database connection details. Creating a new file instead of reusing the old wp-config.php ensures you get rid of any hidden redirect lines that may have crept into it. This process leaves your site as clean as the day it was first installed.
- Delete all WordPress files and folders except your existing
wp-contentandwp-config.php. - Download the latest version of WordPress from the official website and upload it to the server.
- Replace your theme’s files with the originals (from the developer, not from your backups).
Reinstalling Plugins and Themes Manually
- Delete all plugin folders and reinstall each plugin from the WordPress admin dashboard.
- If you use premium themes, download fresh, clean files from the theme developer’s website.
- Make sure all leftovers from old plugin files are completely removed.
Optimizing Server Security and File Permissions
WordPress security depends not only on the software itself but also on how the server it runs on is configured. File permissions (CHMOD) determine which user can read, write or execute which file. Misconfigured permissions make it child’s play for an attacker to upload a file to your site or modify an existing one.
Current cybersecurity practice has made a server-side Web Application Firewall (WAF) standard. Having modules such as mod_security active on your server blocks attacks like SQL injection and Cross-Site Scripting (XSS) before they even reach WordPress. Keeping your PHP version up to date is also vital, since it closes known vulnerabilities in older versions.
The golden rule for file permissions is 755 for folders and 644 for files. For highly critical files such as wp-config.php and .htaccess, however, the most sensible approach is to restrict permissions further (for example 440 or 400) so that only the server can read them. This acts as a physical barrier that stops an attacker from modifying these files even if they manage to get in.
- Always use SFTP (SSH File Transfer Protocol) instead of FTP to encrypt your data.
- Disable directory listing (Directory Browsing) in your hosting panel (cPanel/Plesk).
- Enable “File Change Detection” tools on the server side.
SEO and Google Search Console Recovery After the Cleanup
Removing the malware completely does not mean Google immediately considers your site “clean.” If Google’s bots crawled your site while it was infected, search results will keep showing the warning “This site may harm your computer” next to your site. The only way to remove this warning is to officially notify Google that your site has been cleaned.
Sign in to your Google Search Console account and go to “Security Issues” under “Security & Manual Actions.” There you will see the malicious links and files Google has detected. Once you are sure you have fixed every issue, click “Request Review” and write a detailed description of what you did (plugin cleanup, file replacement, password changes, etc.).
After you submit the review request, Google’s bots will crawl your site again in depth. This usually takes a few days, but if the cleanup was successful, the warnings are removed and your SEO rankings gradually begin to recover. At this stage, regenerating your XML sitemap (sitemap.xml) and submitting it to Google helps bots discover the cleaned pages faster.
- Have your site recrawled through Google Search Console (Request Indexing).
- Check for broken links (404 errors) and remove pages left over from the infection.
- Check your robots.txt file to make sure no rule is left that restricts bot access.
Frequently Asked Questions
1. Does a WordPress redirect virus go away on its own?
No. This kind of malware consists of scripts planted in your system, and they stay active until they are removed manually.
2. Will updating my plugins remove the virus?
Updating plugins can prevent future attacks, but it does not remove malicious code and backdoors that have already gotten into the system.
3. Why are free (nulled) themes dangerous?
Cracked themes often come with hidden redirect code and admin access already built in.
4. Why should I change all passwords after the cleanup?
While they were inside, attackers may have obtained user passwords from the database, so renewing all access credentials after the cleanup is a must.
5. How long does it take Google to remove the warning?
After you submit a review request, Google usually recrawls your site and makes a decision within 24 to 72 hours.
Result
WordPress redirect attacks can be eliminated completely with an accurate diagnosis and a systematic cleanup. Keeping your site updated, using licensed software and running regular security scans is the most effective defense against complex cyber threats.
In summary
In this guide, we walked step by step through how to detect redirect malware on WordPress sites, how to clean .htaccess and the database, automated scanning with effective security plugins, the clean install, setting file permissions and the Search Console recovery process after the cleanup.
















