Apache structure issue (.htaccess) [closed]

好久不见. 提交于 2019-12-08 05:58:04

问题


I have a structure like this

/ < root folder
/Site/Public/.htaccess
/Site/Public/index.php
/Site/Public/error.php
/Site/Public/images/chat.png

In my htaccess I have disabled access to subfolders and set a default 403 document like so:

ErrorDocument 403 error.php
Options All -Indexes

But the problem is that I cannot get it to pick that error.php file unless I use the full path starting from root. I also tried this

ErrorDocument 403 chat.png

And it doesn't pick that up either just displays a string in both situations. Can anyone tell me how to target that error.php file without using the absolute path?

The experimenting url is localhost/Site/Public/images


回答1:


from http://httpd.apache.org/docs/2.2/mod/core.html#errordocument

URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser.

any argument that is not a full url (http://www.example.com) or does not start with / will be treated as string.




回答2:


The urls have to be defined relative to the DocumentRoot, which in your case seems to be the same for your sites.

Alternatively you can use full urls that can be resolved by the client.

That may be an alternative for you.

Everything else you need to know can be read in the manual:

http://httpd.apache.org/docs/current/mod/core.html#errordocument



来源:https://stackoverflow.com/questions/17012875/apache-structure-issue-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!