4

I stumbled upon the fact that my website can 'autocorrect' URLs, when they are close enough to an actual URL:
E.g.

https://example.com/widgets/metric-time.htm

Can also be reached by:

https://example.com/widgets/metric-tim.htm
https://example.com/widgets/metric-timw.htm
https://example.com/widgets/metric-tiem.htm
https://example.com/widgets/metric-times.htm

In the language of the Damerau-Levenshtein distance: by a single deletion/substitution/transposition/insertion respectively.

I confirmed that this works on Chrome, Edge, Firefox, and Internet Explorer.
This suggests that this is not due to the web browser autocorrecting URLs in its history.

Are there common or standardised terms for URL 'autocorrection'?
Such terms could facilitate finding more information about the subject.
E.g. what to expect from different websites and domain providers.
E.g. how to disable it, disable aspects of it, or make it more permissive.
E.g. the exact rules for how the autocorrection occurs.

Are there any standards/protocols?

Finding URL autocorrection information on search engines has been rather difficult.

1 Answer 1

2

This appears to be built-in functionality of WordPress (specifically the redirect_canonical() function). If a user tries to navigate to an nonexistant URL, WordPress will check the URL against its database, try to find a similar one, and 301 redirect the user if it finds one that's close enough.

See the following Stack Exchange posts for more details on this behavior:

WordPress URL Autocorrect - Stack Overflow

Disable Wordpress URL auto complete - WordPress Stack Exchange

Those posts also detail how to disable the functionality. According to the second link, you can use the following one-liner to disable it completely:

With Wordpress 5.5, you can control more precisely if/how the guessing should work. Refer to https://make.wordpress.org/core/2020/06/26/wordpress-5-5-better-fine-grained-control-of-redirect_guess_404_permalink/ for more information. To completely disable guessing, use this code:

add_filter( 'do_redirect_guess_404_permalink', '__return_false' );

If you add this to a new plugin php file (for example in wp-content/plugins/disable-url-autocorrect-guessing.php) you'll have a nice plugin that you can activate to disable Wordpress' autocorrect "guessing" feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.