Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP$服务器[";路径&u信息";]在url中没有index.PHP时不返回信息(htaccess url重写)_Php_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

PHP$服务器[";路径&u信息";]在url中没有index.PHP时不返回信息(htaccess url重写)

PHP$服务器[";路径&u信息";]在url中没有index.PHP时不返回信息(htaccess url重写),php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我有一个php函数,它检测$\u服务器[“PATH\u INFO”],然后分解index.php之后的所有参数。所有URL都使用.htaccess重写 以下是代码供参考: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [L,QSA] 问题是我的重写和php函数在本地工作正常,但在我的测试环境服务器上,

我有一个php函数,它检测
$\u服务器[“PATH\u INFO”]
,然后分解
index.php
之后的所有参数。所有URL都使用
.htaccess
重写

以下是代码供参考:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
问题是我的重写和php函数在本地工作正常,但在我的测试环境服务器上,如果url中没有
index.php
,函数就不会返回
$\u server[“PATH\u INFO”]

例如:

如果我转到
example.com/index.php/this/is/a/test
,函数将为我提供如下数组:
{this,is,a,test}

但是如果我去
example.com/this/is/a/test
重写为
index.php
,但是我的函数什么也没有给我

我已经看到了答案,但我认为这更像是一个服务器配置问题。服务器当前运行在CentOS上,具有OVH版本3配置(类似于cPanel,ISP配置)。web包是Apache2和php5


谢谢你的帮助。✌️

PATH\u INFO
显示脚本名称后面的部分

当请求是
/this/is/a/test
时,没有脚本,因此没有
路径信息

您可以通过使用
REQUEST\u URI
(在第一种情况下包括
index.php
)来解决这个问题,或者添加一个显式查询字符串,例如

RewriteRule ^(.*)$ index.php?path=$1 [L,QSA]

更新

事实证明,我错了。 我最终用一个简单的脚本来测试这个

<?php
echo "PATH_INFO=", $_SERVER['PATH_INFO'];

谢谢你。我们正在重新配置apache服务器,以尝试使其正常工作。将更新