Ben
Ben

Reputation: 2445

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).

At the moment I only have the following rewrite rule in 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: `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? web.config rule? Or is it just my rewrite rule that's wrong?

Edit: This problem seems to have nothing to do with Wordpress's permalink structure! The behaviour is the same if I remove of redirect index.php. I don't think any PHP code is running... this has to be at a higher level.

Upvotes: 0

Views: 1573

Answers (2)

great_llama
great_llama

Reputation: 11729

You can prevent it from happening by changing the Permalink structure option in your WordPress config.

Upvotes: 0

Adam Hopkinson
Adam Hopkinson

Reputation: 28795

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. That would explain why your rewrites are that way - they have the index.php in them before being rewritten.

Upvotes: 1

Related Questions