Apache的结构问题(的.htaccess)结构、问题、Apache、htaccess

2023-09-02 20:32:58 作者:长发绾君心

我有一个这样的结构

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

在我的htaccess我已经禁止访问的子文件夹,并设置一个默认的403文件,像这样:

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

ErrorDocument 403 error.php
Options All -Indexes

但问题是,我不能让它挑选error.php文件,除非我用从根开始的完整路径。我也试过这种

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

和它不会挑选了要么只是显示一个字符串在两种情况下。谁能告诉我如何定位的error.php文件,而无需使用绝对路径?

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?

该实验网址是本地主机/网站/公共/图像

推荐答案

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

网址可以用斜线(/)为本地网络路径(相对于开始   DocumentRoot的),或者是它的客户端可以解析一个完整的URL。   替代地,要由要显示可以提供一个消息   浏览器。

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.

任何参数不是一个完整的URL( http://www.example.com )或不以 / 将被视为字符串。

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