阻止IIS7重写将“index.php”添加到重定向路径?

时间:2009-05-08 15:22:38

标签: php iis iis-7 rewrite

我正在尝试使用PHP5(fastcgi)为IIS7上的Wordpress MU 2.7配置rewrite规则。

目前我在Web.config中只有以下重写规则:

         <rule name="Canonical Host Name" stopProcessing="true">
             <match url="(.*)" />
             <conditions logicalGrouping="MatchAll">
                 <add input="{HTTP_HOST}" negate="true"
                      pattern="^subdomain\.example\.com$" />
             </conditions>
             <action type="Redirect"
                     url="http://subdomain.example.com/{R:1}"
                     redirectType="Permanent" />
         </rule>

在我输入网址(见下文)时,它会重定向到正确的主机名,但出于某种原因,请使用index.php/预先添加路径:

url: `http://subdomain/my/path/123`
redirects to: `http://subdomain.example.com/index.php/my/path/123`
should redirect to: `http://subdomain.example.com/my/path/123`

有没有人知道为什么会这样,以及如何防止这种情况发生?

我错过了某个服务器设置或某事......? php.ini中? web.config规则?或者只是我的重写规则是错的?

编辑:这个问题似乎与Wordpress的永久链接结构无关!如果删除重定向index.php,行为是相同的。我不认为任何PHP代码正在运行......这必须处于更高的水平。

2 个答案:

答案 0 :(得分:1)

Wordpress,默认情况下(我认为),将友好永久链接格式化为index.php / path / to / post,因为这模仿重写而不需要服务器支持重写。这可以解释为什么你的重写是这样的 - 在重写之前它们中有index.php。

答案 1 :(得分:0)

您可以通过WordPress配置中的changing the Permalink structure选项阻止它发生。