How to undo a website redirect: find where it lives, remove it safely, clear cached 301s, and spot when the redirect is actually malware.
Knowing how to undo a website redirect starts with one question: who put it there? If you or a developer set it up, you can remove it in a few minutes. If you didn't, it's a symptom of a compromised site, and deleting one line won't fix it. The redirect will come back. This guide covers both cases, in the order we'd check them.
First, Confirm the Redirect Is Real and Not Just Cached
A permanent (301) redirect can stay in a browser's cache long after you've removed it from the server. Google's documentation on redirects explains that permanent redirects tell browsers and search engines the old address has moved for good. That's why you can delete a rule and still land on the wrong page.
Before you edit anything, rule out the cache:
- Open the site in a private or incognito window.
- Try a different device on mobile data, not your office Wi-Fi.
- Clear your browser cache for that domain, then test again.
- Test with a header checker or `curl -I https://yourdomain.com` to see the actual status code (301, 302) and the `Location` target.
If the redirect only happens on your own browser, you're done. If it shows up everywhere, keep going. If it only happens for some visitors, such as people arriving from Google or on phones, treat that as a red flag. Hackers often hide redirects from site owners and logged-in admins.
Where a Redirect Can Live
Redirects aren't stored in one place. Work through these layers from the outside in. Stop when the behaviour changes.
1. DNS, CDN, and domain registrar
Registrars often offer 'domain forwarding'. Cloudflare and similar services have page rules or redirect rules. If the redirect happens before your server is even reached, check these dashboards first. Look for forwarding rules you don't recognize.
2. Hosting control panel
cPanel and similar panels have a 'Redirects' tool that writes rules into your `.htaccess` file. Delete the offending entry there. It's the cleanest method on Apache hosting.
3. The .htaccess file or server config
On Apache, look for `Redirect`, `RedirectMatch`, or `RewriteRule ... [R=301]` lines. A standard WordPress `.htaccess` is short: a `# BEGIN WordPress` block with a handful of rewrite lines. Anything beyond that, especially long, obfuscated rules or conditions that check for the visitor's referrer or user agent, deserves suspicion. On Nginx, the equivalent is `return 301` or `rewrite` in the server block.
4. WordPress settings and plugins
Check Settings β General for the WordPress Address and Site Address. A wrong value there can redirect the entire site. Then review redirect and SEO plugins (Redirection, Rank Math, Yoast Premium and similar) for rules, and look for plugins you don't remember installing. If you can't log in, rename the `/wp-content/plugins` folder over SFTP to deactivate everything at once, then restore it and reactivate plugins one at a time.
5. Theme files and the database
A redirect can also be a few lines of JavaScript or PHP in `header.php`, `functions.php`, or `wp-config.php`. It can be injected into post content or the `wp_options` table. This is the usual hiding place for malicious redirects.
If you delete a redirect and it reappears within a day, you didn't remove the redirect. You removed the symptom.
Removing a Redirect You Set Up Yourself
Back up the file or plugin settings first. Then remove the specific rule, save, and test in a private window. A few judgment calls:
- Temporary move (302) you're finished with: delete it. The original URL works again right away.
- Permanent move (301) you want to reverse: delete it, but expect a lag. Browsers may remember the 301, and search engines can take days or weeks to reindex the original URL.
- Old HTTP-to-HTTPS or www rules: don't delete these unless you're replacing them. Removing them can create duplicate versions of your site.
- Redirect loops: if you get 'too many redirects', two rules are fighting, often a plugin versus `.htaccess`, or a CDN set to 'Flexible' SSL against a server that forces HTTPS. Remove one side.
If you're reversing a real site move, Google's guidance on site moves with URL changes is worth reading. Keep redirects in place for a while rather than yanking them out all at once.
When the Redirect Isn't Yours: Treat It as Malware
Signs the redirect is malicious: it sends people to pharmacy, gambling, or fake-prize pages. It only fires from search results or on mobile. Rules in `.htaccess` keep returning after you delete them. Admin users or plugins appear that nobody created. In that case, undoing the redirect is only step one.
A proper cleanup means finding the backdoor that put the rule there, removing it, changing every credential, and updating whatever was vulnerable. Otherwise the infection reinstalls itself. Our post on what a real cleanup involves walks through that process. For the diagnostic side, see why your site sends visitors elsewhere. If you'd rather hand it off, our website malware removal service handles the whole job, including the cleanup and the hardening afterward.
After the Redirect Is Gone
- Test the homepage, a few inner pages, and a page reached from a Google search result.
- Check Google Search Console for security issues and manual actions, and request a review if you were flagged.
- Change hosting, WordPress admin, database, and SFTP passwords if there was any chance of a compromise.
- Update WordPress core, themes, and plugins, and delete any you don't use.
- Keep a dated copy of your working `.htaccess` so you can compare it later.
The takeaway: a redirect you created is a one-line fix, but a redirect you didn't create is a security problem. Check the cache, work through the layers, and ask whether the rule keeps coming back. If it does, stop deleting it and get the infection cleaned out. Our related guide on what to do when your own website sends visitors somewhere else covers the next steps.
References
- Google Search Central β Redirects and Google Search
- Google Search Central β Site moves with URL changes
This article is general educational information, not professional, medical, or purchasing advice. External links are provided for reference; DS Web Solutions Inc. is not affiliated with and does not endorse any third-party brand or organization listed.



