简体   繁体   English

.htaccess重写规则重定向到404页面

[英].htaccess rewrite rule redirect to 404 page

I have a few folders such as php_includes templates and a few others and I am adding a .htaccess file for them all. 我有一些文件夹,例如php_includes templates ,还有一些其他文件夹,我正在为它们全部添加.htaccess文件。 So far what I have works if the user trys to directly access the file in the address bar, but I'd rather it send it to a 404 page. 到目前为止,如果用户尝试直接访问地址栏中的文件,那么我的工作正常,但我希望将其发送到404页面。

IndexIgnore *
# no one gets in here!
deny from all
#error 404
ErrorDocument 404 /error/404.html

Is there something wrong with my .htaccess All I feel like is happening is the deny from all is taking over so the 404 won't work directly. 我的.htaccess是否有问题,我感觉正在发生的一切是所有人都拒绝接管,因此404无法直接运行。 Though I've tried this with a different .htaccess file for the main site, and the 404 isn't working in there either. 尽管我已经使用主站点的其他.htaccess文件尝试了此操作,但404也不在其中工作。

Same ErrorDocument as the others but here is how my directory is set up 相同ErrorDocument为别人,但这里是我的目录是如何设置的

  -.htaccess
 --public_html
   --error
     --404.html
 --admin

So maybe I am either getting the ErrorDocument incorrect for my .htaccess that or I have the path directory incorrect. 因此,也许是我的.htaccess文件错误了ErrorDocument ,或者我的路径目录不正确。 Can someone please explain what the issue here is? 有人可以解释一下这里的问题吗?

note I am using 000webhost if that matters sometimes I see them doing some silly stuff, and this is just a testing server. note备注我正在使用000webhost如果这很重要,有时我会看到他们在做一些愚蠢的事情,但这只是一个测试服务器。

Since you are using deny directive it sends error code 403 . 由于您正在使用deny指令,因此它将发送错误代码403

Declare your custom handler for 403 : 声明403的自定义处理程序:

ErrorDocument 403 /error/404.html

The deny from all directive will generate a 403 error. 全部拒绝指令将产生403错误。 So just do this 所以做这个

ErrorDocument 403 /error/404.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM