我在共享主机上有这样的结构:
~/above_public_html/public_html/directory_i_want_forbidden
我有一个 ~/above_public_html/.htaccess
,其中包含以下内容:
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
当我导航到不存在的文件或文件夹时,我会弹出 404.html,没有问题。
当我导航到存在但具有 chmod 700
权限的子文件夹或文件(包括 directory_i_want_forbidden
)时,我得到:
Forbidden
You don't have permission to access /directory_i_want_forbidden on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at www.mydomain.com Port 80
我需要做什么才能使 ErrorDocument 403/403.html
正常工作?
最佳答案
.htaccess 或 httpd.conf 上游有些问题。因为我使用共享主机,所以我无法控制它。此后,我启动了自己的 Amazon EC2 服务器实例,一切都按预期运行。
关于linux - 错误文档 403 不适用于子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15150171/