WordPress Site Redirecting to Another Website? What's Happening and How to Stop It

If your WordPress site is sending visitors to a casino, pharmacy, or unfamiliar spam page, treat it as a possible security incident. A WordPress site infected with a redirect may still look normal to you while customers are being sent elsewhere.
The redirect might happen on every visit, or only on a phone, in a private browser window, or when someone arrives from Google. That inconsistency can make the problem hard to spot, but it doesn’t mean the issue is harmless. Here’s how to check what’s happening and what to do next.
Why does a hacked WordPress site redirect visitors?
A redirect can be caused by a legitimate setting or plugin, but if the destination is unfamiliar or the change was unexpected, malicious code is one possible cause. Attackers may add code in places that control how your site loads or where visitors are sent, including:
- Theme or plugin files: Code added to a file such as a theme’s
functions.phpcan run when pages load. .htaccessor other server rules: A changed configuration file may redirect requests before WordPress displays a page.- The WordPress database: Injected scripts or changed site settings can alter a page or send visitors elsewhere.
- A malicious administrator account: An unfamiliar user with administrator access may be able to change settings, add code, or install software.
- A hidden backdoor: A backdoor is code that lets an attacker regain access after an obvious change has been removed.
Some redirects are also cloaked: they’re designed to show only under certain conditions. For example, the code may redirect mobile visitors, people who arrive from Google, or visitors who aren’t logged in as an administrator. The owner may see the normal site and mistakenly assume the problem is gone.

How to check whether your WordPress site is redirecting
Start with simple checks. Don’t click links or download anything from the unexpected destination. If the site appears to be serving harmful content, avoid opening suspicious pages directly; Google recommends safer diagnostic options such as Search Console’s URL Inspection tool for some investigations.
- Open your site in a private or incognito window. This helps rule out some effects of your normal browser session.
- Try another device and connection. Check on a phone as well as a computer. If possible, test using mobile data instead of your usual Wi-Fi.
- Compare direct visits with search visits. Type your address into the browser, then separately try reaching the site from a search result. A redirect that happens only after a search click may be checking the visitor’s referrer.
- Check more than one page. The redirect might affect only certain URLs, or only the first page people land on.
- Ask your hosting provider to investigate. The host may be able to check server logs and files, or confirm whether a server-level issue is involved.
You can also review Google Search Console’s Security issues report. Its sample URLs can help you spot affected pages, but Google notes that the examples may not show every affected URL. Its Security issues report guide explains how to review findings and request a review after cleanup.
What to do if your WordPress site is hacked and redirecting
Removing a visible redirect is not the same as cleaning a hacked site. If the code that put it there, or the access that allowed it to be added, remains, the redirect can return.
1. Record what you see and contact your host
Write down when you noticed the redirect, which pages and devices were affected, and what the destination looked like. Keep screenshots or browser messages if you can do so safely. Tell your hosting provider that you suspect a compromised WordPress site and ask whether they can help preserve a copy, inspect logs, or temporarily limit access while you investigate.
WordPress’s guide for hacked sites also recommends documenting symptoms and checking with your host. If your site is on shared hosting, ask whether other sites or the hosting environment may be involved.
2. Preserve a backup before changing things
Before you delete files or edit the database, ask your host about taking a backup or snapshot of the current site. It may contain malicious code, but it can also help with investigation or recovery if something goes wrong during cleanup. Keep it separate from any backup you intend to restore.
A known-clean backup from before the compromise may be useful, but restoring it alone may not fix the weakness or stolen credentials that allowed the intrusion. Discuss the safest approach with your host or a qualified security professional.
3. Secure accounts and remove access you don’t recognize
Change passwords for WordPress administrators and other users who can access the site. Also change relevant hosting, SFTP or FTP, database, and email passwords, especially if they were reused. Use unique passwords and enable two-factor authentication where available.
Review your administrator list for accounts you don’t recognize. Don’t assume that changing a WordPress password alone will secure the whole hosting account. WordPress includes broader steps for responding to a compromise in its hacked-site guidance.
4. Find the source across files and the database
The redirect may be in .htaccess, a theme or plugin file, a database record, or another part of the hosting environment. A careful cleanup checks more than the one line or file that appears suspicious. It also looks for unknown files, injected scripts, altered settings, unfamiliar administrator users, and ways an attacker could regain access.
Avoid deleting unfamiliar code unless you know what it does and have a reliable backup. A change that seems small can break your site, and removing only the visible redirect can leave the underlying access in place.

5. Close the entry point and harden the site
Once the malicious code is removed, address the likely route in: for example, outdated software, an exposed account, or a compromised hosting login. Update WordPress, themes, and plugins, and remove software you no longer use. Use trusted sources for replacements.
The official WordPress hardening guide covers practices such as strong passwords, updates, backups, and limiting access. Hardening reduces risk, but no single setting can guarantee that a site will never be compromised again.
The Hack Remover helps WordPress owners with cleanup of malicious code and backdoors, access-risk remediation, and site hardening. If you’re not sure whether to handle this yourself, our step-by-step hack response guide and cleanup comparison cover the decision in detail.
Why does the redirect come back after I delete it?
If a redirect returns, something may still be restoring it or adding it again. The cause might be another infected file, a malicious database entry, an administrator account you missed, or a scheduled task that rewrites a configuration file. A caching layer can also make old behaviour appear to persist, so clearing relevant caches is worth discussing with your host.
Don’t keep deleting the same redirect line without investigating what recreates it. Ask your host or security professional to look for the source across the site, database, and hosting environment, then test again on mobile, desktop, and through search traffic.
What to do about a Google warning
If Google shows a security warning or Search Console lists a security issue, clean the problem throughout the site first. Google advises fixing all reported issues across affected pages, testing the fixes, and then requesting a review through the Security issues report. Review timing can vary; a request is not an instant removal of a warning.
For background, see Google’s Security issues report guidance. Keep a record of the cleanup steps and what you changed so you can describe them clearly if you request a review.
What should you tell customers?
If customers may have encountered the redirect, a short, factual notice can help. For example:
“We’re investigating an issue affecting our website. If you were redirected away from our site, please don’t enter personal or payment information on the page you were sent to. We’ll share an update when the site is safe to use.”
Share the notice through a channel customers can verify, such as your established social media account or a direct email. Don’t speculate about what information may have been exposed; confirm that through your host or security investigation.
A redirect is stressful, especially when customers are trying to reach your business. But it is a problem you can investigate methodically: confirm when it happens, preserve evidence, secure access, find and remove the source, and verify the site before asking Google to review it.