On my Drupal sites if I go to fake url like: mysite.com/.htacess/nothing-here I get a 403 Forbidden (never hits Drupal). Is there a way we can redirect it to a 404 instead of 403?
In order to catch server 403 as custom 404 you need to use the ErrorDocument directive (assuming you're using Apache HTTP Server) :
In the event of a problem or error, Apache httpd can be configured to do one of four things :
- output a simple hardcoded error message
- output a customized message
- internally redirect to a local URL-path to handle the problem/error
- redirect to an external URL to handle the problem/error
So to let Drupal handle the document, set the following (httpd.conf) :
ErrorDocument 403 /index.php
Note : Additional environment variables are available when an error redirect is sent : these variables are generated from the headers provided to the original request by prepending REDIRECT_
onto the original header name. This provides the error document the context of the original request (eg. REDIRECT_URL
, REDIRECT_STATUS
, REDIRECT_QUERY_STRING
).