无法访问“错误”消息subdomain.localhost / error /中的文件夹 [英] Cant Access a "error" folder in subdomain.localhost/error/
问题描述
我正尝试将所有错误文档放入网站根目录中的一个文件夹中。
I am trying to put all of my error documents into one folder in my website root.
理想情况下,我希望所有错误文档都放入 http://subdomain.localhost/error/
,但是每当我在浏览器中加载URL时,都会显示一条消息 禁止访问!
错误403
。
Ideally I would like all of my error documents to go into http://subdomain.localhost/error/
but whenever I load the URL in my browser I get a message Access forbidden!
Error 403
.
然后我删除了 .htaccess
文件根目录中的文件。 .htaccess
文件的内容为:
I then removed the .htaccess
file from the document root. The content of the .htaccess
file is:
ErrorDocument 403 /err_docs/401
ErrorDocument 401 /err_docs/401
ErrorDocument 404 /err_docs/404
ErrorDocument 500 /err_docs/500
IndexIgnore * # prevent directory listing
Order deny,allow
Allow from *
/ err_docs /
是我当前保存错误文档的文件夹-(因为 / error
不起作用)。
/err_docs/
is my current folder for my error documents - (Because /error
doesn't work).
检查apache错误日志后,我发现:
[2015年6月25日星期四13:46:57.445385 [autoindex:error] [pid 5104:tid 1760] [客户端127.0.0.1:51853] AH01276:无法提供目录C:/ xampp / apache / error /:没有匹配的DirectoryIndex(index.php,index.pl,index.cgi,index.asp,index.shtml,index.html, index.htm,default.php,default.pl,default.cgi,default.asp,default.shtml,default.html,default.htm,home.php,home.pl,home.cgi,home.asp,home。 shtml,home.html,home.htm),并且服务器生成的目录索引被禁止通过Options指令
Upon inspecting the apache error log I find:
[Thu Jun 25 13:46:57.445385 2015] [autoindex:error] [pid 5104:tid 1760] [client 127.0.0.1:51853] AH01276: Cannot serve directory C:/xampp/apache/error/: No matching DirectoryIndex (index.php,index.pl,index.cgi,index.asp,index.shtml,index.html,index.htm,default.php,default.pl,default.cgi,default.asp,default.shtml,default.html,default.htm,home.php,home.pl,home.cgi,home.asp,home.shtml,home.html,home.htm) found, and server-generated directory index forbidden by Options directive
我尝试了以下操作:
- 从文档根目录中删除了
.htaccess
。 (来自子域和域)。 - 检查apache的文件夹中是否没有其他
.htaccess
文件
- Removed
.htaccess
from the document root. (From both the sub domain and the domain). - Checked that there isn't another
.htaccess
file in apache's folders
我很高兴能在Google上找到搜索结果,但我不知道要搜索什么。谁能告诉我从哪里开始寻找问题或寻找什么?
I am happy to go finding the result on google but I have no idea what to search. Can any body tell me where to start looking for the issue, or what to look for?
更新
这是内容我的虚拟主机配置文件:
Update This is the contents of my virtual hosts config file:
NameVirtualHost localhost:80
<VirtualHost *:80>
<Directory "C:\web">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ServerName localhost
ServerAlias localhost
DocumentRoot "C:\web"
</VirtualHost>
#######################################
NameVirtualHost localhost:80
<VirtualHost *:80>
<Directory 'C:\\Personal\\Web'>
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ServerName personal.localhost
ServerAlias personal.localhost
DocumentRoot 'C:\\Personal\\Web'
</VirtualHost>
#######################################
推荐答案
我今天遇到了完全相同的问题。在谷歌搜索时,我遇到了这个问题。由于问题没有得到解答,所有评论都没有帮助我,因此我提出了一个新的问题,并观察到/ error是从 ServerRoot ,而不是 DocumentRoot 。在评论中,我建议检查/ error的别名。最后,我在文件 xampp / apache / conf / extra / httpd-multilang-errordoc.conf 中获得了别名。注释 Alias
指令可使文档根目录中的 error 文件夹可访问。请注意,注释别名可能会有副作用,因为其他配置文件中/ error文件夹文件有很多用途,主要是用来定义 ErrorDocument
。
I was having exactly same problem today. While googling I came to this question. Since the question was unanswered and none of the comments helped me, I asked a new question with my observation that /error was being served from ServerRoot instead of DocumentRoot. In the comments I got a suggestion to check for an alias for /error. Finally I got the alias in the file xampp/apache/conf/extra/httpd-multilang-errordoc.conf. Commenting the Alias
directive makes error folder in document root accessible. Please note that commenting the alias may have side-effects as there are many uses of /error folder-files in other configuration files mostly to define ErrorDocument
.
这篇关于无法访问“错误”消息subdomain.localhost / error /中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!