Hey guys I need help with htaccess file
Suppose I have a site called site.com when I try to give a URL site.com\a it will automatically redirect to site.com\about-me page and same for other letters as well is there way to redirect all the non existing URLs to 404
CodePudding user response:
Wordpress automaticly handles invalid url requests. If invalid urls not redirect to 404 page you should check your .htaccess file. If Wordpress can redirect default 404 page, you can edit your existing 404.php file or create new one. Here is redirect code for your 404.php file:
header("Location: your about-me page url");
CodePudding user response:
I think I found the solution!
Adding this to the function file solves the problem I am facing it's a new feature in WordPress 5.5 version to auto-redirect to the nearest match URL if an incorrect URL is entered.
add_filter('do_redirect_guess_404_permalink','stop_redirect_guess');
function stop_redirect_guess() {
return false;
}