php $_SERVER[REQUEST_URI] 取值问题
$_SERVER['REQUEST_URI'] 取值问题测试WEB服务器
apache 2.2.8
nginx 1.3.3
iis 7.5
1,返回结果
apache
普通模式
["QUERY_STRING"]=>
string(16) "cid=1&newsid=100"
["REQUEST_URI"]=>
string(26) "/test.php?cid=1&newsid=100"
["argv"]=>
array(1) {
[0]=>
string(16) "cid=1&newsid=100"
}
重写模式
.htaccess 文件内容
测试地址:http://localhost/test-1-100
RewriteEngine On
RewriteRule ^test-([0-9]+)-([0-9]+)$ test.php?cid=$1&news=$2 [L]
["QUERY_STRING"]=>
string(14) "cid=1&news=100"
["REQUEST_URI"]=>
string(11) "/test-1-100"
["argv"]=>
array(1) {
[0]=>
string(14) "cid=1&news=100"
}
iis 7.5
普通模式
["QUERY_STRING"]=>
string(14) "cid=1&news=100"
["SCRIPT_NAME"]=>
string(9) "/test.php"
重写模式
web.config 文件内容
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="test" stopProcessing="true">
<match url="^test-([0-9]+)-([0-9]+)$" ignoreCase="false" />
<action type="Rewrite" url="test.php?cid={R:1}&news={R:2}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
["HTTP_X_ORIGINAL_URL"]=>
string(11) "/test-1-100"
["QUERY_STRING"]=>
string(14) "cid=1&news=100"
["SCRIPT_NAME"]=>
string(9) "/test.php"
nginx 1.3.3
普通模式
["SCRIPT_NAME"]=>
string(9) "/test.php"
["REQUEST_URI"]=>
string(26) "/test.php?cid=1&newsid=100"
["QUERY_STRING"]=>
string(16) "cid=1&newsid=100"
重写模式
rewrite "^/test-([0-9]+)-([0-9]+)$" /test.php?cid=$1&news=$2 last;
["SCRIPT_NAME"]=>
string(9) "/test.php"
["REQUEST_URI"]=>
string(11) "/test-1-100"
["DOCUMENT_URI"]=>
string(9) "/test.php"
["QUERY_STRING"]=>
string(14) "cid=1&news=100"
- 上一篇:php分词器原理分析
- 下一篇:无限树型简约版Tree