Canonical redirect may be confusing to the average WordPress user, yet they can have a big influence on search engine optimization. This article's goal is to provide you with all of the necessary information concerning them.
Simply said, if a single page can be reached through many URLs, Google will treat them as duplicates of the same page and will choose only one URL as the canonical one to be indexed. If this occurs on your website, Google will either pick the URL for you or consider both URLs to be equal, which might result in a substantially lower rank in search results. Even worse, the search engine may pick the incorrect page as the original, displaying outdated content.
The article not only explains the nature of the problem, but it also offers some useful suggestions for dealing with the duplicate URLs issue.
Duplicate content can be a real nightmare for both visitors and search engines. Regardless of how bad it seems, this is a simple problem to solve. In essence, canonicalization is all you need to take control and tell search engines which pages you want them to crawl. You may use a meta tag with a canonical URL or a "301 redirect" or a combination of the two.
Despite its flaws, WordPress can handle this issue quite reliably. Now we will look at one of its built-in features that aims to solve the issue of duplicate permalinks.
Why is canonicalization important for SEO?
What are canonical URLs?
The good news is that those of you who use WordPress are in luck. Few people are aware that WordPress automatically inserts this tag into the page code, even if no SEO plugin is installed. If necessary, there is a dedicated function that you may use to get the canonical URL for a certain post or page.
What is a canonical redirect?
Simply said, alternative URLs may be accessed because WordPress identifies them dynamically using so-called "rewrite rules" based on regular expressions (REGEX). 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.
So, how does WordPress make advantage of canonical redirects? The best way to ensure that both users and search engines are forwarded to the proper page is via a server-side redirection. In order to do this, WordPress uses the "redirect_canonical()" function, which is intended to prevent duplicate content penalty by redirecting all incoming links to the canonical one.
URL in the old (raw) format:
Canonical URL (redirect target):
Guess 404 permalink redirect
What is more, the canonical redirect functionality contains one additional, lesser-known component: the "redirect_guess_404_permalink()" function. When a user enters a URL that does not exist based on the precise WordPress query, it attempts to 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.
This "guess-redirect" feature is useful for both SEO and UX, but it might cause some strange behavior in certain circumstances. If you have discovered that any of your URLs are redirecting to odd URLs and articles, you should turn it off. The code snippet that you may use to do so is provided in the final section of this article.
What is an "old slug redirect"?
Apart from addressing the duplicate content issue with canonical redirects, WordPress has another interesting feature that was built specifically to avoid SEO penalties.
It is lesser-known "Old slug redirect," which functions similarly to canonical redirect. To put it simply, it provides a fallback for old URLs following a native slug change, preventing the potentially catastrophic "404 not found" error.
To begin, WordPress keeps the previous version of the slug as a custom field (_wp_old_slug) in the database whenever you modify it. Then, when someone tries to open any URL in the front-end, the function will check the requested URL address to determine if the extracted slug was previously used as a slug to any page. If this is the case, WordPress will initiate a redirect to the canonical permalink.
Let us assume we created a page called "Cape Verde" and WordPress generated the slug "cape-verde" from it.
Then we modified the title and native slug to "Cabo Verde" and "cabo-verde" respectively. The original slug "cape-verde" was kept in the database, and now anyone accessing the old URL (see above) will be forwarded to the new one (see below).
Redirect target URL:
This particular functionality is rarely used. As mentioned above WordPress saves the old slugs in wp_postmeta table using '_wp_old_slug' meta key. The other problem here is that there is no easy way to list all the saved slugs that will trigger the redirect.
How does canonical redirect affects custom permalinks?
As you may know, the URL changes may lead to 404 ("not found") error. In order to avoid this, the plugin has fallback mechanism for the old permalinks. In short, any non-canonical URL variants will be automatically routed to the canonical URL specified by the plugin.
This functionality could be helpful, after you use Permalink Manager to adjust permalinks. In practice, any (original) URLs that were active prior to the installation of plugin will be automatically redirected to the new permalinks.
Old (native) URL:
New URL (custom permalink, redirect target):
How to disable redirect functions?
You can deactivate both "Canonical redirect" and "Old slug redirect" in Permalink Manager settings. These functionality is available also in free version of plugin (Permalink Manager Lite).
If you do not want to install a separate plugin, you may use the following snippet to disable redirect functions:
# 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' );
Frequently asked questions
Why does the old URL appear in Google's search results?
It is possible that even after you have activated the canonical redirect, the old URL will appear in Google search results and Search Console. Because of the way Google's crawler works, this is not necessarily a negative thing.
Google will not instantly erase the old URL from its search results even if a canonical redirect redirects the user to the new one. This is done on purpose, since websites sometimes have technical issues and downtime, and Googlebot will not instantly remove a URL from the index if it is detected to be missing.
You should be aware that bigger websites get crawled more often than smaller websites that generate less organic search traffic. In the worst-case situation, if you have a small website with few visitors, an outdated URL may continue to display in search results for months.