I have a page URL that uses this format: http://site/pagetitle. However, I am experiencing an issue where WordPress is redirecting any page URL that resembles this format, such as /pagetitl, /pagetit, /pageti, and even /p, to the actual page titled /pagetitle. This is causing an issue for me as I have another idea for a page URL that coincidentally uses part of the same page title, and it is also being automatically redirected to this same existing page.
I am attempting to resolve this by adding a new rewrite URL in the .htaccess file. When I use the htaccess tester on madewithlove, the output is as expected. However, on my site, it continues to redirect any page URL that starts with even the first character of the page title to the actual page titled /pagetitle.
Can anyone help me to identify the cause of this issue?
It’s a bit hacky, but this should work:
function no_redirect_guess_404_permalink( $header ){
global $wp_query;
if( is_404() )
unset( $wp_query->query_vars[‘name’] );
return $header;
}
add_filter( ‘status_header’, ‘no_redirect_guess_404_permalink’ );
WordPress uses a function known as “guessing” to prevent 404 errors. You can find a plugin called “disable-url-autocorrect-guessing” at https://wordpress.org/plugins/disable-url-autocorrect-guessing/ that will turn off this function. Additionally, you can refer to https://wordpress.stackexchange.com/questions/28045/stop-wordpress-from-guessing-redirects-for-nonexistent-urls to learn how to stop WordPress from guessing redirects for nonexistent URLs.