Why does my website keep redirecting to spam pages?
Summary
This guide helps you troubleshoot and resolve: Why does my website keep redirecting to spam pages?. Follow the steps below to fix the issue.
Quick Tip: Need immediate assistance? 💻 Open a Ticket
Common Causes
Unexpected website redirects occur when visitors are sent to pages they did not request, often leading to spam, phishing sites, or malicious downloads. This behaviour is typically caused by compromised website files, injected malicious code, or unauthorised changes to your site's configuration. Left unresolved, these redirects can destroy visitor trust and harm your search engine rankings.
Quick Fix Steps
- Scan your website files for unfamiliar code or recently modified scripts.
- Restore your site from a clean backup taken before the redirects began.
- Update all website software, including your content management system, themes, and plugins.
- Change all administrative, FTP, and database passwords.
- Remove any unrecognised administrator users from your website dashboard.
Detailed Instructions
1. Identify the Source of the Redirect
- Open your website in an incognito or private browser window to bypass cached redirects.
- Use your browser's developer tools (
F12on Windows,Command + Option + Ion macOS) to inspect network requests and identify where the redirect originates. - Check your website's root directory for recently modified files, particularly
.htaccess,index.php, andwp-config.php. - Review your website's admin dashboard for any plugins or extensions you did not install.
If the redirect only happens on mobile devices or specific search engines, the malicious code may be hidden in your theme files or database rather than your main configuration.
2. Clean Affected Files
Warning: Before cleaning or modifying any files, take a full backup of your website files and database. If something goes wrong during the cleaning process, a backup ensures you can restore your site to its current state.
- Download a fresh copy of your website's core files from the official vendor.
- Compare your current files against the clean versions to spot injected code.
- Remove any suspicious JavaScript, iframe embeds, or encoded strings found in template files.
- Check your
.htaccessfile for unauthorised rewrite rules that force redirects to external domains. - Scan your website using a reputable security scanner to identify remaining malware.
If you do not have a clean backup available, download the latest clean version of your content management system core files from the official vendor. Manually re-upload your media and content, but do not overwrite core files with potentially infected versions. Consider engaging a professional security service to clean the database if you lack technical experience.
Do not simply delete the
.htaccess file without first backing it up, as this may break your site's permalinks or security rules.3. Update Software and Credentials
- Log in to your website's admin panel. For WordPress, go to Dashboard > Updates. For Joomla, go to Components > Joomla! Update.
- Install all available updates for your content management system, themes, and plugins.
- Delete any unused plugins or themes, as outdated inactive extensions can still be exploited.
- Change your hosting control panel password, FTP/SFTP password, and database password.
- Review all user accounts with administrator access and remove any you do not recognise.
4. Access Files via cPanel
- Log in to your cPanel account provided by your host.
- Open File Manager and navigate to the
public_htmldirectory. - Right-click files such as
index.phpor.htaccessand select Edit to review code for suspicious injections. - Use the Virus Scanner tool in cPanel to scan your home directory for known malware signatures.
Troubleshooting
Redirects Persist After Cleaning
- Clear all caching layers, including your website cache, browser cache, and any content delivery network (CDN) cache.
- Check your domain's DNS settings for unauthorised changes to A records or CNAME records.
- Log in to your domain registrar's control panel and verify that the nameservers and contact details have not been changed without your authorisation. If you suspect registrar-level hijacking, contact your registrar's support team immediately to regain control of your domain.
Server-Level Redirects
- If the redirect occurs before your website files load, the issue may be in your server configuration. Check for malicious rules in Apache
.htaccessor Nginx configuration files. - Review scheduled tasks or cron jobs in your hosting control panel for unfamiliar scripts that may be injecting redirect code.
- If you cannot locate the source at the file or application level, contact your hosting provider to inspect server-level configurations and request assistance.
Search Engine Warnings Appear
- Register your site with Google Search Console to review security issues and manual actions.
- Request a review once your site is clean to remove browser and search warnings.
- Submit your updated sitemap to help search engines reindex clean pages.
Host Has Suspended Your Account
- Your hosting provider may suspend accounts detected serving malware to protect other customers.
- Work with your provider to clean the site before requesting reactivation.
- Ensure all vulnerabilities are patched to prevent immediate reinfection.
If you host with us, you don't need to do this yourself — just Open a Ticket and our Brisbane team will get it sorted.
Still Having Issues?
Need more help? If the issue persists after trying these steps, please open a support ticket and our team will assist you.
💻 Open a Ticket
💻 Open a Ticket