keepcalculator

06 Numbers and Powers

301 Redirect Not Working? Fix It in 5 Steps

Card No. 06·39607 · Updated · Standard formula, shown below

If your 301 redirect isn’t working, the cause is almost always a caching issue, a server misconfiguration, or the redirect being placed after content that already sent a response. This article explains the most common culprits and gives you a step-by-step fix to make your redirects work reliably.

What a 301 Redirect Does

A 301 redirect is a permanent status code that tells browsers and search engines that a URL has moved to a new location. When implemented correctly, it passes the majority of the original page’s ranking signals to the new URL, ensuring users and search engines land on the right page. It is the standard method for migrating a website, changing domain names, or consolidating duplicate content.

Why Your 301 Redirect Might Not Work

Several factors can cause a 301 redirect to fail. The most frequent are:

  • Browser caching: Your browser may have stored the old redirect, so you keep seeing the old page even though the server is sending the correct response.
  • Server caching: A caching plugin or server-side cache (like Varnish or Cloudflare) might be serving a cached version of the page, bypassing the redirect.
  • Incorrect redirect placement: If you place the redirect code after sending HTML or other output, it won’t work because the server has already committed to sending the response.
  • Redirect loops: A chain of redirects where A points to B, B points to C, and C points back to A will cause an error.
  • Syntax errors: A simple typo in the redirect rule (e.g., missing a slash, using the wrong variable) can make it ineffective.
  • HTTPS/HTTP mismatch: Redirecting from HTTP to HTTPS, or vice versa, without a proper rule can cause issues.

How to Diagnose the Problem

Before changing anything, check what the server is actually returning. Use a tool like curl -I from your terminal or an online HTTP status checker. Look at the status code and the Location header. If you see 301 and a Location header, the redirect is working at the server level—the problem is likely caching. If you see 200 or 404, the redirect rule isn’t being applied.

Step-by-Step Fixes

  1. Clear your browser cache: Hard refresh (Ctrl+F5 or Cmd+Shift+R) or use incognito mode to bypass cached redirects.
  2. Purge server caches: If you use a caching plugin (like WP Super Cache or W3 Total Cache), clear the cache. If you use Cloudflare, purge the cache or temporarily pause it to test.
  3. Check the redirect rule placement: In an .htaccess file, redirect rules must come before any other rewrite rules that might interfere. In server config files, ensure the redirect is in the correct server or location block.
  4. Verify the pattern: For .htaccess, a typical rule looks like:
    Redirect 301 /old-page https://www.example.com/new-page
    For mod_rewrite, use:
    RewriteRule ^old-page$ https://www.example.com/new-page [R=301,L]
  5. Test with a fresh URL: Add a query string to the URL (e.g., ?test=1) to bypass any cached version. If the redirect works with the query string, caching is the issue.

Common Scenarios and Solutions

Scenario 1: Redirect works on one page but not another. This often happens when the redirect rule is too specific. For example, a rule for /old-page won’t match /old-page/ (with a trailing slash). Use a more general pattern or add both versions.

Scenario 2: Redirect works in a browser but not in a crawler. Search engine crawlers may not follow JavaScript-based redirects (e.g., window.location). Always use server-side redirects for SEO-critical pages.

Scenario 3: Redirect from HTTP to HTTPS fails. Ensure you have a rule that catches all HTTP traffic and redirects it to HTTPS, and that your HTTPS certificate is valid.

Alternatives to 301 Redirects

In some cases, a 301 redirect isn’t the best option. If the old URL is temporary, use a 302 (temporary) redirect. If you want to serve different content based on device type, use a Vary: User-Agent header. For content that has been removed, consider returning a 410 Gone status to tell search engines to remove it faster.

Frequently Asked Questions

Why is my 301 redirect showing a 404 error?

A 404 error means the redirect rule isn’t matching the requested URL. Double-check the path in the rule, including trailing slashes and case sensitivity. Also, ensure the rule is placed before any other rules that might rewrite the URL.

How long does it take for a 301 redirect to take effect?

Server-side redirects take effect immediately. However, browsers and search engines may cache the old URL for a short time. Clearing your browser cache and using a tool like Google Search Console’s URL Inspection can help you see the updated status.

Can a 301 redirect hurt my SEO?

No, a properly implemented 301 redirect passes most of the ranking signals to the new URL. However, redirect chains (A to B, B to C) can dilute some link equity, so it’s best to redirect directly to the final URL.

What is the difference between 301 and 302 redirects?

A 301 is permanent and passes link equity; a 302 is temporary and does not pass link equity. Use 301 for permanent changes and 302 for temporary ones, like A/B testing or maintenance pages.

My redirect works on www but not non-www. Why?

This usually happens when your redirect rule only matches one version of the domain. Ensure you have a rule for both, or use a wildcard pattern. Also, check your DNS and server configuration to ensure both versions point to the same server.

How do I fix a redirect loop?

A redirect loop occurs when a redirect points to a URL that eventually redirects back to the original. Check all your redirect rules and remove any that are circular. Use a tool like curl -I -L to trace the full chain of redirects and identify the loop.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →