我在我的本地服务器上有一个奇怪的redirect问题。 我有一个VirtualHost设置:
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "/Users/iMac/Sites/index.php" ServerName jordan.local ErrorLog "/private/var/log/apache2/jordan.local-error_log" CustomLog "/private/var/log/apache2/jordan.local-access_log" common <Directory "/Users/iMac/Sites/index.php"> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
访问http://jordan.local工作正常。 但是,当我尝试访问一个子目录jordan.local/somefolder/index.php ,显示的页面是jordan.local/index.php 。 我没有一个.htaccess文件,并重新启动了无数次的Apache。
Apache版本:2.2.22(Unix)
Mac OS X 10.7.5
这是我的主机文件,如果有任何帮助:
127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost #74.208.10.249 gs.apple.com 127.0.0.1 jordan.local
我访问的所有本地URL(不存在)都显示在我的自定义访问日志中,作为200响应代码。
我的Apache错误日志给出这个警告:
Warning: DocumentRoot [/Users/iMac/Sites/index.php] does not exist
虽然/Users/iMac/Sites/index.php是一个有效的path。
如果您需要更多信息,请让我知道。
请将DocumentRoot更改为指向一个目录,而不是文件。 参考: http : //httpd.apache.org/docs/2.2/mod/core.html#documentroot
的DocumentRoot
DirectiveDescription :构成从Web可见的主文档树的目录
语法 :
DocumentRoot directory-path默认 :
DocumentRoot /usr/local/apache/htdocs上下文 :服务器configuration,虚拟主机
状态 :核心
模块 :核心
这个指令设置
httpd将为其提供文件的目录。 除非通过像Alias这样的指令进行匹配,否则服务器会将所请求URL的path附加到文档根目录,以创build文档的path。例:
DocumentRoot /usr/web
那么访问
http://www.my.host.com/index.html是指/usr/web/index.html。 如果目录path不是绝对的,则假定它是相对于ServerRoot。应该指定
DocumentRoot而不使用斜线。