How to Stop WordPress from Guessing URLs

If you are using WordPress for any part of the time, then you may probably know that when you enter a wrong URL of any WordPress blog or website, WordPress tries to guess the URL.

For instance, if a user tries the URL and if there is no content associated with that URL, then WordPress tries to guess the URL for the user and redirects them to the URL

This happens because the URL has the word “hello” in it.

As useful as it is, WordPress is not exactly good at guessing URLs and often times makes the mistake of redirecting users to unmatched content.

In fact, getting 404 errors is far better than automatic guessing as it enables you to manually correct the URL or missing links.

So, if you ever want to, here are different methods to disable or stop WordPress from guessing URLs and instead issue 404 Not Found errors.

Stop URL Guessing – Method 1

The first way to stop WordPress from guessing URLs is to use the below code. To do that, open up your theme’s functions.php file.

Once opened, copy and paste the below code and reupload the file.

remove_filter('template_redirect', 'redirect_canonical');

That’s all there is to do. From this point forward, WordPress no longer tries to guess the URL and issues a 404 Not Found error.

Once thing to keep in mind while using the above code is that it completely disables the canonical redirection, which is pretty helpful in terms of SEO.

Stop URL Guessing – Method 2

If you want more SEO friendly way to stop WordPress from guessing URLs. i.e, without completely disabling the redirect_canonical filter, then use the below code.

Simply copy and paste the below code in your theme’s functions.php file or the site-specific plugin and you are good to go.

add_filter('redirect_canonical', 'bs_no_redirect_404');
function bs_no_redirect_404($redirect_url)
    if (is_404()) {
        return false;
    return $redirect_url;

Stop URL Guessing Using the Plugin

If you are uncomfortable copying and pasting the above code snippets then you can use the free WordPress plugin Disable URL Autocorrect Guessing.

Simple install and activate the plugin and you are good to go. The plugin contains the same code that is shared above and being a simple plugin, there are no settings or configurations to mess around.


That’s all for now and it is that simple to stop WordPress from guessing URLs. You may also want to know how to restore missing link title field in Insert model box in WordPress editor. So, do check it out.

Hopefully that helps and do comment below sharing your thoughts and experiences on how to stop WordPress from guessing URLs.

1 Comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.