.htaccess中的DocumentRoot导致错误

时间:2020-03-06 14:48:55  来源:igfitidea点击:

我的.htaccess文件中有DocumentRoot / var / www / test。这导致apache服务器给我500个内部服务器错误。

错误日志文件显示:
警报] [客户端127.0.0.1] /var/www/.htaccess:此处不允许使用DocumentRoot

AllowOveride全部在我的conf文件中设置。

知道为什么会这样吗?

解决方案

DocumentRoot指令不能出现在.htaccess文件中。将其放在" httpd.conf"中。

应该在VirtualHost指令中而不是.htaccess文件中设置DocumentRoot。

我们将DocumentRoot放在.htaccess文件中的任何特定原因吗?

我们没有提到apache版本,但是2.0版的文档说DocumentRoot仅对virtualhost或者服务器配置有效。根据文档,不应在.htacces中使用它

http://httpd.apache.org/docs/2.0/mod/core.html#documentroot