如何从GET方法中删除index.php和变量

时间:2016-10-27 13:52:58

标签: windows iis-7 web-config

我需要将www.mysite.pl/?title=title-of-my-site&id=123更改为www.mysite.pl/some-text/123/

在我的web.config中:

<rule name="topic" >
    <match url="^topic\/([_0-9a-z-A-Z-]+)\/([0-9]+)\/" />
    <action type="Rewrite" url="index.php?title={R:1}&amp;id={R:2}" />
</rule>

并将此配置更改为www.mysite.pl/some-text/123/index.php?title=title-of-my-site&id=123

有什么问题?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案!

问题出在PHP代码中,其中有很多重定向,这取决于url模式。 e.g:

if(strpos($_SERVER['REQUEST_URI'], "index.php")===false and $_SERVER['QUERY_STRING']<>"" and strpos($_SERVER['QUERY_STRING'], "topic")===false and strpos($_SERVER["REQUEST_URI"], "pattern1,")===false and strpos($_SERVER["REQUEST_URI"], "pattern2,")===false and strpos($_SERVER['QUERY_STRING'], "error_page")===false) {
header ('HTTP/1.1 301 Moved Permanently');
header("Location: index.php?".$_SERVER['QUERY_STRING']);
die();
}