Understanding Canonical Redirect in WordPress

Having the same content accessible through different URLs can negatively impact SEO. This situation makes it hard for search engines to decide which URL to display in search results.

When analyzing a website search engine crawlers can identify different URL versions of the same page. This can result in the wrong URL being indexed.

A practical way to prevent this is by using canonicalization to define specific URL as the preferred one. Applying a canonical redirect clearly signals the preferred URL. This helps to ensure the correct page shows up in search results.

Canonical redirect graphic

What Is Canonicalization?

Sometimes, a single page ends up having several versions of its URL. This can be simply the result of extra parameters that tools for tracking or referrals add to the original address. To avoid confusion and SEO issues, you should explicitly tell crawlers which version of the URL is the preferred primary address.

Consider these URLs, all leading to the exact same content:

https://example.com/sample-page/
https://example.com/sample-page?ref=instagram
https://www.example.com/sample-page/1/

Without a canonical URL specified, search engine crawlers struggle to pick the definitive version for results. Left undefined, these variations might compete against each other in search rankings.

What Are Canonical URLs?

Although it has no direct influence on "human" visitors, a canonical URL serves one purpose and is important for SEO. In a nutshell, the canonical URL indicates search engine crawlers the desired URL for a certain page when they index the website.

Considering the problem of duplicated content, there is a possibility that you have a post or page that appears under multiple URL variants. When search engines crawlers determine the "canonical" URL, only that URL will be utilized for displaying search results.

Essentially, Google consider this canonical URL as the most accurate one. If you use WordPress, things are a little easier. Whether you use an SEO plugin or not, WordPress inserts a meta tag with the canonical URL into the HTML code of your single posts and pages.

WordPress started adding the meta tag with canonical URL in 2010 with version 2.9. Interestingly, this feature was limited to single posts and pages only.

Adding canonical tags to category or author archive pages requires extra steps. You will have to either use an SEO plugin or insert the meta tag through custom code snippet.

How Do You Find a Canonical URL?

The easiest way to find a page's canonical URL is by checking its HTML source code. This is helpful, but the meta tag itself does not promise that Google will always respect it.

When a page exists at several URLs, Google might pick a different version to show in search results. Therefore, using a canonical redirect is an additional precaution to make sure the preferred URL is used.

Meta tag in HTML source

What Is A Canonical Redirect?

A canonical redirect ensures that a specific page is always accessed through just one main URL. If a page can be reached by several different addresses, visitors are automatically sent from any alternate version to the preferred, canonical one.

Canonical redirects play an important role for several reasons. They make sure that the SEO value from backlinks does not get lost when URLs change but instead moves to the updated links.

Besides that, they help signal which page should be treated as the main one. This reduces the chance of duplicate content appearing, which means the search engines do not waste their crawling budget.

There are two key types of redirects, each sending a different message through HTTP status codes:

  1. The more common one is the 301 redirect, which signals that the original content has been moved permanently to another address.
  2. The other type is the 302 redirect. This one is less frequent and is meant for temporary moves. It works well if you only want to move content for a brief period and plan to bring it back.

Canonical Redirect In WordPress

The reason alternative URLs may deliver identical content is that WordPress uses "rewrite rules", which depend on regular expressions (REGEX) to loosely match URLs. The term or post will be loaded as long as the URL follows the general URL pattern and the last component (slug) matches an existing content item.

To manage this, WordPress applies the "redirect_canonical()" function. It redirects any alternative URLs to the canonical version, reducing the risk of duplicate content penalties.

URL in the old (raw) format:
https://example.com/?p=123

Canonical URL (redirect target):
https://example.com/canonical-permalink-of-page-with-id-123/

Guess 404 Permalink Redirect

What is more, the canonical redirect functionality contains one additional, lesser-known component: the "redirect_guess_404_permalink()" function. When you enter a URL that does not exist based on the precise WordPress query (due to a typo or a broken link), it will redirect the user to a similar link. In other words, it tries to "correct" the requested URL and send a visitor to the actual URL address.

Both SEO and UX can benefit from this "guess-redirect" function, although in some cases, it can result in unexpected behavior. Turn it off if you have found that any of your URLs are leading visitors to the incorrect pages and articles. The code snippet that you may use to do so is provided in the final section of this article.

URL with the typo:
https://example.com/product/shirts/cotton/pique-polo

Canonical URL (redirect target):
https://example.com/product/shirts/cotton/pique-polo

Old Slug Redirect

WordPress also includes a lesser-known "Old slug redirect" functionality that works in a slightly different way than canonical redirect. In short, this feature helps prevent "404 not found" errors by handling outdated URLs after a native slug has been changed.

What happens behind the scenes is that WordPress saves the previous slug as a custom field named "_wp_old_slug". So, when a visitor requests a URL, WordPress sees if the slug has ever been used before. If it does, it quietly sends the visitor over to the updated URL.

For example, imagine you created a page titled "Cape Verde", which generated the slug "cape-verde".

Old URL:
https://example.com/africa/cape-verde/

If you later update the title to "Cabo Verde" and change the slug to "cabo-verde", the old slug remains in the database. Anyone visiting the original URL will be redirected to the new address:

Redirect target URL:
https://example.com/africa/cabo-verde/

At first, this feature appears very useful. However, it operates behind the scenes and offers very limited control. The main challenge is that you cannot get a list of all saved slugs that trigger redirects, so analyzing them is difficult.

Troubleshooting

Canonical redirects help avoid duplicate content by sending users to the preferred URL, but they only work if configured properly. Conflicts such as redirect loop often arise when plugins interfere or when server-level rules override them.

To identify the source, examine HTTP response headers. When a redirect is called using wp_redirect() function, it includes a header called "X-Redirect-By".

If this header contains the value “WordPress”, it means the redirect was triggered by WordPress itself. If a plugin name appears instead, then that plugin is the one handling the redirect.

HTTP response with "X-Redirect-By" headerIt is also useful to deactivate your plugins and theme one at a time to test where the issue might be coming from. If none of these steps work, there are additional tips and solutions covered later in this guide.

How To Disable Canonical Redirect?

The default canonical redirect functions work reliably in most cases. Yet, it can sometimes interfere with custom code or plugins. To address this, you can use the PHP code snippet below to disable canonical redirect completely or only their single components.

# Disable canonical redirect completely
remove_action( 'template_redirect', 'redirect_canonical' );
# Disable "old slug" redirection
remove_action( 'template_redirect', 'wp_old_slug_redirect' );
# Disable "guess 404 permalink" redirection
add_filter( 'do_redirect_guess_404_permalink', '__return_false' );

If you do not have experience with PHP or already use the Permalink Manager plugin, you can disable this feature in the plugin’s settings. This option is also available in the free version (Permalink Manager Lite).

Canonical redirect settings

URL changes often lead to frustrating 404 "not found" errors. To prevent this, the Permalink Manager plugin includes a robust fallback mechanism for old permalinks. It automatically redirects any non-canonical URL variations to the canonical URL defined within the plugin.

Permalink Manager offers two main methods to prevent 404 errors when outdated URLs are accessed.

Redirecting Original WordPress URLs

The first feature automatically redirects original WordPress URLs to their updated custom permalinks. However, WordPress still needs to recognize those original links.

You do not need to change anything in the default settings. Just leave the built-in permalink settings untouched in "Settings -> Permalinks", and the plugin will handle the rest using the custom permalinks and Permastructures.

Old (native) URL:
https://example.com/shop/old-original-product-permalink/

New URL (custom permalink, redirect target):
https://example.com/new-url-set-with-permalink-manager/

Automatic redirect
The native permalink (team/john-doe) was used before Permalink Manager was installed. It will lead to new custom permalink (staff/john-doe) set in Permalink Manager.

The second method "old custom permalink redirect", needs to be enabled manually in the plugin settings. It records every previously used custom permalink so that if a permalink changes, the previous version is automatically redirected to the new one.

How to enable extra redirects & old permalinks fallback

Last updated by Maciej Bis on: July 24, 2025.


Maciej BisFounder of Permalink Manager & WordPress Developer

The developer behind Permalink Manager, a plugin for managing permalinks, has been working with WordPress, creating custom plugins and themes, for more than a decade.

Go up