Send a 404 error via htaccess?

2019-01-23 23:39发布

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?

2条回答
▲ chillily
2楼-- · 2019-01-24 00:16

You could also for the time being change which page a user will see when confronted with a 403 error, but I wouldn't recommend doing this long-term.

.htaccess:

ErrorDocument 403 /your404pagehere.php
查看更多
别忘想泡老子
3楼-- · 2019-01-24 00:18

Try:

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

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

查看更多
登录 后发表回答