WEBSITE RECOVERY
WordPress Redirecting to Spam? A Safe Recovery Plan
A WordPress site that sends visitors to gambling, shopping or download pages needs more than a redirect plugin reset. Contain the harmful behaviour, identify where the redirect is introduced, close the access route and test the restored site across realistic visitor journeys.

Confirm the redirect pattern before changing files
Record the affected URL, time, device, browser and route into the website. Does the redirect happen when a visitor arrives from search, when viewing a product, or only on the first visit? Google has documented hacked redirects that target selected visitors, so a clean visit from your usual administrator browser is weak reassurance. Do not repeatedly open an unsafe destination on an everyday work device.
| Observed behaviour | Useful next check |
|---|---|
| Search visitors redirect; direct visits look normal | Compare the same public page through both journeys in an isolated investigation environment. |
| Every page redirects immediately | Inspect server rules, application bootstrap and hosting/CDN redirect configuration. |
| Only one page or button redirects | Inspect that page content, template and scripts before assuming the whole server is clean. |
A legitimate marketing redirect, an incorrect domain setting and an injected redirect require different fixes. Preserve the evidence that distinguishes them. A browser extension can also alter a single person's experience; reproduce the problem on a separate trusted environment before declaring that every visitor is affected.
Contain the redirect without losing the evidence
Ask the hosting provider to retain access logs, account activity and a snapshot of the affected files and database. Store copies privately, with timestamps and access restricted to the response team. Treat the snapshot as evidence, not as a clean restoration point. Note each emergency change so a later investigator can reconstruct what happened.
If visitors are being sent to harmful pages, restrict the affected application at the hosting or web-server layer. An application maintenance plugin may run after the malicious code and can leave the redirect active. Use a short service notice on a trusted route, and give customers an independently verified contact method. Consider pausing ads that direct people into an unsafe journey.
Trace the redirect to its actual source
Work from the outside inward: domain and DNS changes, CDN rules, web-server configuration, application files, database content and browser-loaded scripts. Review newly added administrators and recent deployments alongside these layers. The first suspicious line found is an indicator, not a complete incident scope.
- Review .htaccess or equivalent server rules, unexpected PHP bootstrap changes and altered configuration files.
- Inspect active themes, plugins, must-use plugins, custom snippets, widgets and database-stored header or footer scripts.
- Check page-builder templates, advertising tags and tag-manager accounts that can add code without changing the visible article body.
- Compare affected responses with approved source packages or a trustworthy deployment record. Record unexplained differences before replacement.
Do not use a blanket search-and-delete operation for every redirect or external domain. Payment gateways, booking systems and sign-in services may depend on legitimate external destinations. Have the site owner confirm business integrations and retain only those that are needed and verified.
Remove the malicious change and the route back in
- Establish trusted hosting and administrator access from a clean device. Secure the recovery email account if it may be involved.
- Replace compromised executable components from verified publisher or deployment sources. Review custom code separately; reinstalling WordPress does not replace every custom file or database value.
- Remove unauthorised accounts, scripts and configuration changes after recording the evidence. Investigate other sites sharing the same hosting identity.
- Patch or remove the component that allowed access, or revoke the compromised account or deployment credential. If the cause is uncertain, document that uncertainty and consider rebuilding on clean infrastructure.
- Rotate relevant secrets and invalidate sessions once the environment can protect the new values. Include hosting, CMS, deployment, database and exposed integration credentials as the incident scope requires.
- Purge relevant application and CDN caches after cleanup, then verify that a cached malicious response is no longer being served.
A scanner can help locate suspicious files, but a clean scan cannot explain a stolen hosting session or an unsafe deployment process. Require a short explanation of initial access, persistence and the controls changed to prevent the same route being used again.
Verify public behaviour, not just the dashboard
Test logged-out and logged-in journeys, mobile and desktop layouts, a fresh browser profile, search entry pages and the pages customers originally reported. An investigator may compare crawler-like requests to expose conditional malware, but the repaired site should serve legitimate equivalent content to visitors and crawlers. Do not create special clean responses solely to pass a review.
Check the response chain, final destination, loaded script domains and forms. Confirm that checkout, contact and account recovery still work. Repeat the checks after the site has handled ordinary traffic and scheduled tasks. Define a monitoring period with the business owner rather than claiming that one successful page load proves permanent cleanliness.
A practical handover example
Hypothetical example: a UK service company finds that visitors from search are redirected, while staff bookmarks work normally. Investigation links the redirect to an unauthorised script in a shared page template. Removing that script restores the page, but the team also discovers an unfamiliar editor account and an exposed deployment password. The handover therefore records both the content repair and the access changes, plus the pages and journeys retested.
For hacked website redirect recovery in the UK, ask for an evidence-led scope rather than a promise to delete a fixed number of files. CyberXperts can help assess the affected layers and plan restoration. Provide the domain, symptoms, hosting platform and last known good date through a secure contact route; never send passwords in an ordinary enquiry.
Frequently asked questions
Why does WordPress redirect only on mobile or from Google?
Malicious code can make decisions using visitor context, cookies or request information. A configuration error can also affect selected paths. Capture the exact journey and compare responses safely; do not assume the absence of a redirect in your administrator session means the issue is fixed.
Will deleting a redirect plugin remove the hack?
Only if that plugin is the sole source and the attacker no longer has access. A redirect can live in server rules, another component, database content or an external script account. Investigate the access route and persistence before treating plugin removal as recovery.
Can a CDN cache keep showing a malicious redirect?
A cached response can outlast an origin repair, depending on the cache rules. Preserve useful evidence, clean the origin and relevant configuration, then purge the affected cache. Verify the public response afterwards rather than assuming the purge completed the investigation.
Should I redirect every hacked URL to the homepage?
No. Restore legitimate pages at their intended URLs where possible, and handle attacker-created pages according to whether genuine replacement content exists. Sending unrelated spam URLs to the homepage can confuse visitors and hide unresolved routing problems.
How quickly will search traffic recover?
There is no reliable fixed timescale. Technical cleanup, security review, recrawling and ranking changes are separate processes. Record which one is still pending and monitor the relevant reports instead of buying a guarantee that the original position will return.
Sources and further reading
Official documentation and advisories supporting the technical points above. The recovery workflows and examples are editorial guidance for adapting to your own systems.
- Google Search Central: Helping Webmasters with Hacked Sites — accessed 22 October 2026
- WordPress: FAQ My site was hacked — accessed 22 October 2026
Get practical support for your next step.
Tell CyberXperts what happened, which systems are affected and what you have already checked. Do not include passwords or sensitive incident evidence in the initial form.
Discuss your website security