为什么我的文档根目录显示在PATH_INFO,PATH_TRANSLATED和PHP_SELF中?

时间:2016-08-23 11:28:02

标签: php apache .htaccess mod-rewrite virtualhost

我设置了VirtualHost,如下所示:

<VirtualHost *:80>
       ServerName ownedmedia.vzweb07.example.co.uk
       DocumentRoot /var/www/vhosts/owned_media_microsite/httpdocs
       ErrorLog /var/www/vhosts/owned_media_microsite/logs/error_log
       CustomLog /var/www/vhosts/owned_media_microsite/logs/access_log combined
       SetEnv ENVIRONMENT 'development'
       <Directory /var/www/vhosts/owned_media_microsite/httpdocs>
               AllowOverride All
               allow from all
               Options +Indexes
       </Directory>
</VirtualHost>

我在DocumentRoot中有一个.htaccess文件,如下所示:

AddDefaultCharset UTF-8

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)

RewriteRule ^(.*)$ index.php/$1 [L]

当我访问http://ownedmedia.vzweb07.example.co.uk/admin/modules/load/coreg_api_module/rule/1var_dump $_SERVER数组时,我看到以下内容...(我已经删除了一些不相关的值)。

["DOCUMENT_ROOT"]=>
string(46) "/var/www/vhosts/owned_media_microsite/httpdocs"
["SCRIPT_FILENAME"]=>
string(56) "/var/www/vhosts/owned_media_microsite/httpdocs/index.php"
["REDIRECT_URL"]=>
string(43) "/admin/modules/load/coreg_api_module/rule/1"
["REQUEST_METHOD"]=>
string(3) "GET"
["QUERY_STRING"]=>
string(0) ""
["REQUEST_URI"]=>
string(43) "/admin/modules/load/coreg_api_module/rule/1"
["SCRIPT_NAME"]=>
string(10) "/index.php"
["PATH_INFO"]=>
string(52) "/httpdocs/admin/modules/load/coreg_api_module/rule/1"
["PATH_TRANSLATED"]=>
string(123) "redirect:/index.php/httpdocs/httpdocs/admin/modules/load/coreg_api_module/rule/1/admin/modules/load/coreg_api_module/rule/1"
["PHP_SELF"]=>
string(62) "/index.php/httpdocs/admin/modules/load/coreg_api_module/rule/1"

为什么PATH_INFO等包含httpdocs目录?

httpdocs内的目录甚至没有名为httpdocs的目录,因此PATH_TRANSLATED无法正确。

有没有人对为什么会这样做有任何想法?这个项目已经设置好了,并且在其他主机上运行正常,我在这台机器上还有其他vhosts没有遇到同样的问题。

1 个答案:

答案 0 :(得分:0)

奇怪的是,我能够通过删除文档根目录中的所有内容然后重新上传来解决这个问题。 也许这是一个错误的htaccess文件。