Stop WordPress from Guessing URLs / Stop WordPress from auto-correcting URLs
// ---------------------------------
// Method 1: More SEO Friendly
// ---------------------------------
add_filter('redirect_canonical', 'bs_no_redirect_404');
function bs_no_redirect_404($redirect_url)
{
if (is_404()) {
return false;
}
return $redirect_url;
}
/*
* A more SEO friendly way to stop WordPress from guessing URLs.
* i.e, without completely disabling the redirect_canonical filter
*/
// ---------------------------------
// Method 2:
// ---------------------------------
remove_filter('template_redirect', 'redirect_canonical');
/*
* Completely disables the canonical redirection
*/
// Source: https://www.bloggersignal.com/stop-wordpress-from-guessing-urls/