Search code examples
.htaccesshttp-status-code-404http-status-code-403

Send a 404 error via htaccess?


I'd like to cut off access to a subdirectory on my site but I want any access in the subdirectory to be a 404 error, not a 403 forbidden. How can this be accomplished?


Solution

  • Try:

    RewriteRule ^directory/ - [L,R=404]
    

    This redirects all requests for the folder "/directory/", they get a 404 response.