How to Identify the Source of a WordPress Redirect?

Redirects can help website owners to maintain a consistent user experience and improve SEO. They are useful, but they may also have drawbacks that affect site performance, and search engine results.

WordPress use the redirect function for a number of reasons, and many other third-party plugins do the same. What may go wrong here is that the multiple redirects controlled by different plugins start to mix together, preventing visitors from accessing your content.

Dealing with an unwanted redirect can be frustrating and hard to pinpoint. The "redirect loop" is one of the most annoying problems WordPress may have. This article can help you in finding and fixing not just the redirect loop, but also any unwanted redirections.

HTTP Request

Redirect Types

HTTP Status Codes

Technically speaking, redirects are just HTTP status codes that tell browsers to go to an other URL. They are primarily categorized into two types: temporary and permanent.

  • Permanent redirect
    The "301 Moved Permanently" redirect is often used when the domain or website structure changes.
  • Temporary redirect
    The “302 Moved temporarily” status code is sent when the requested URL has been temporarily relocated.

Redirect Sources

In WordPress, redirections can occur due to various reasons including plugins, theme settings, or server configurations.

Server Configuration

One common source of the redirect could be the server settings. If this is the case, identifying its source may be really challenging. As a first step, you should check the NGINX configuration settings or the .htaccess file for Apache servers.

WordPress Core

The WordPress core includes built-in functionality for handling certain types of redirects. For example, when you change the slug of a post or page, WordPress automatically sets up the canonical redirect from the old URLs to the new ones to ensure that existing links continue to work correctly.

Plugins/Themes

With WordPress, you may find a plethora of plugins that provide redirection functionality. Among these are plugins like "Redirection" and "Yoast SEO" which allows users to create custom redirect rules and handle 301 redirects.

Likewise, many themes have redirection functions as part of their feature set. For instance, a theme may forward visitors after form submissions or login attempts.

Identifying the Issue

Infinite Redirect Loops

Identifying the redirect loop is far easier than determining the source of it. You should be able to see it when you open the webpage, but your browser keeps redirecting you and does not show the content you are expecting.

Different browsers may show the redirect loop warning in different ways. However, they usually result in an error message. It states that the browser detected too many redirects and that the page cannot be loaded.

Chrome, for example, displays the error code "ERR_TOO_MANY_REDIRECTS". Firefox shows an error message saying "The page isn't redirecting properly", similar to Safari's message "Safari Can't Open the Page".

Redirect loop message

Solving the Problem

Analyzing HTTP Headers

In order to see any website, your browser must first submit a request to a server, which must then deliver a response. The response contains HTTP headers with basic metadata about the response, including details on any redirection that has taken place.

In WordPress, the redirects performed by the native wp_redirect() function send an extra HTTP header: "X-Redirect-By".

Its default value is "WordPress", but many plugins, including Yoast SEO or Permalink Manager, alter it to the name of the plugin, making it possible to determine where the redirect originated.

HTTP response with "X-Redirect-By" header

You can inspect the HTTP headers directly in the developer tools using your browser. Another option is to make use of one of the online tools like the "HTTP Status Code Checker" or "Redirect Checker".

Deactivating the plugins

If you have a WordPress site with multiple plugins installed, one plugin may be redirecting users to a different page while another plugin is redirecting them back creating a loop.

To identify the source of the redirect loop, you can deactivate each plugin one by one until the issue is resolved.

WP Core Monitor

In case WordPress' built-in functions are the cause of the redirect, you may use a little plugin named WP Core Monitor to track down its source. It determines whether the redirect was caused directly by the WordPress core, a 3rd party plugin or theme.

Using the tool is simple. Just download it from the official Github repository and install it like any other plugin.

WP Core Monitor backtraces the redirectThis plugin will help you monitor and analyze the backtrace data, allowing you to pinpoint the specific function responsible for the redirect. By identifying the root cause, you can make necessary code adjustments or deactivate conflicting plugins to resolve the issue.

SEO Impact

While the redirections serve various purposes such as updating outdated links or managing site restructuring, they can significantly impact both SEO and UX. This is a critical consideration, particularly if an unexpected redirect happens, since this might result in major SEO and UX issues.

If a URL redirects traffic elsewhere, like through an unwanted redirect, it can cause the original URL to lose its link equity or "link juice". This can lead to a drop in search engine ranking for that page.

Higher Bounce Rates

Each redirection adds an additional HTTP request-response cycle. This increase page load time, especially if multiple redirections are involved. Furthermore, slow-loading websites annoy visitors and may result in increased bounce rates.

Poor Navigation Experience

Redirections may also break the natural navigation flow, making it difficult for users to return to the previous page. This is especially annoying for users who want to revisit a certain content.

by Maciej Bis

Leave a Reply

Your email address will not be published. Required fields are marked *