404 error - htaccess redirects invalid request to home page not 404

admin2025-05-31  1

Trying to work out how to get Wordpress / .htaccess to show a 404 error page for invalid requests.

With a default WP .htaccess file a request like

/?exam=testing.html

will redirect to the home page but it retains the invalid request as the URL.

The issue is that Google is treating this as a 'successful' load of a page that is a hacked 'exam papers site' page and listing the site as hacked.

Trying any invalid page request gives the same result like:


Options seem to be :

  1. get .htaccess to drop the request when redirecting to the Home Page so that the URL is only the / - however this is still incorrectly suggesting a successful page from the request

  2. prefer to see a 404, 403 or even 401 to clearly show that it was an invalid request and present an appropriate error page, so that Google tests will get an appropriate result, and humans creating errors will also be told.

However, trying to search results for the above provide a plethora of pages explaining how to avoid 404 errors, and not how to have them.

Any help appreciated.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748624045a313601.html

最新回复(0)