我正在重写,但它不适合我。我已经为此浪费了 2 天时间。您的帮助将不胜感激。
RewriteRule test/(.*)/(.*)/$ /include/test?$1=$2 //not working
RewriteRule test/(\w+)/(\w+)/$ /include/test?$1=$2 //not working
RewriteRule ^test/(\w+)/(\w+)/$ /include/test?$1=$2 //not working
RewriteRule .* include/test.php?id=123 //working
尝试 PHP 代码
echo $_SERVER['PHP_SELF'] // include/test.php/id/1234 (after rewrite)
// expecting : /include/test.php?id=1234
用户网址请求:
http://www.example.com/include/test/id/1234
改写至:
http://www.example.com/include/test.php?id=1234
可能的问题:
- 不获取 $1、$2 的值
- 不匹配模式(尽管模式是当前的)
- 不重定向到替代品(内部)
主要问题:
得不到$_GET
价值
测试.php
<?php
ini_set("display_errors",1);
echo $_GET['id'];
echo $_SERVER['PHP_SELF'].'<br/>';
echo $_SERVER['PATH_INFO'];
?>
请求时
http://www.example.com//include/test/id/1234
输出:
/include/test.php/id/1234
/id/1234