简体   繁体   English

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

[英]Prevent IIS7 rewrite from adding “index.php” to path on redirect?

I am trying to configure rewrite rules for a Wordpress MU 2.7 on IIS7 with PHP5 (fastcgi). 我正在尝试使用PHP5(fastcgi)在IIS7上为Wordpress MU 2.7配置重写规则。

At the moment I only have the following rewrite rule in Web.config: 目前,我在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>

At the moment when I enter a URL (see below) it does redirect to the right hostname but for some reason prepends the path with a index.php/ : 当我输入一个URL(见下文)时,它确实重定向到了正确的主机名,但是由于某种原因在路径前加上了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`

Does anyone have an idea why this is and how I can prevent this from happening? 有谁知道这是为什么,以及如何防止这种情况发生?

Am I missing a certain server setting or something...? 我是否缺少某个服务器设置或其他东西? php.ini? php.ini? web.config rule? web.config规则? Or is it just my rewrite rule that's wrong? 还是仅仅是我的重写规则错了?

Edit: This problem seems to have nothing to do with Wordpress's permalink structure! 编辑:此问题似乎与Wordpress的永久链接结构无关! The behaviour is the same if I remove of redirect index.php . 如果删除重定向index.php则行为相同。 I don't think any PHP code is running... this has to be at a higher level. 我认为没有任何PHP代码正在运行...这必须处于更高的水平。

Wordpress, by default (I think), formats friendly permalinks as index.php/path/to/post, as this mimics rewriting without requiring the server to support rewriting. 默认情况下(我认为),Wordpress会将友好的永久链接的格式设置为index.php / path / to / post,因为它模仿了重写而无需服务器支持重写。 That would explain why your rewrites are that way - they have the index.php in them before being rewritten. 那可以解释为什么您使用这种方式进行重写-在重写之前,它们中包含index.php。

您可以通过在WordPress配置中更改“永久链接”结构选项来防止发生这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM