在IIS + PHP上重写url后获取url?

时间:2015-01-03 00:18:53

标签: php iis url-rewriting

我的IIS将http://example.com/wiki/Main(重写前的网址)重写为http://example.com/w/index.php?title=Main(重写后的网址)。

在index.php中,$_SERVER['REQUEST_URI']会返回wiki/Main

我使用Windows 2008 Server,IIS 7,PHP 5.4。重写工具是IIS URL重写模块2.我是PHP,IIS和网站的新手。

重写前或重写后REQUEST_URI是否引用了网址?

如果REQUEST_URI是重写前的网址,我怎样才能在重写后获取网址?

1 个答案:

答案 0 :(得分:0)

尝试解析$ _GET全局数组:

$URL = $_SERVER['PHP_SELF'] . '?'; // index.php?
for ($_GET as $key => $value)
{
    $URL .= $key . '=' . $value . '&';
}

或类似的东西。基本上,所有URL =关联都存储在$ _GET。