search ]

Disable WordPress URL Guessing

URL Guessing is a built-in WordPress feature that attempts to perform automatic redirects when a user lands on an incorrect URL. In other words, WordPress tries to guess the URL and redirects the user to an address similar to the wrong one entered in the browser bar, so instead of getting a 404 page, the user is redirected to the address WordPress thinks they meant.

To disable this feature, add the following code to your theme’s functions.php file:

<?php

function sv_no_redirect_404($redirect_url)
{
	if (is_404()) {
		return false;
	}
	return $redirect_url;
}
add_filter('redirect_canonical', 'sv_no_redirect_404');
Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo