Php – Configuring WordPress rewrite rules on IIS7.5 inside virtual application

iis-7.5PHPrewriteweb.configWordpress

I have to configure WordPress into a virtual application under a principal website running on ASP.NET 2.0 Classic mode.

Everything is working fine, PHP 5.3.13 / MySQL 5.1 / IIS 7.5, the wordpress site also work fine, except for the rewriting side.

The blog is host at www.mysite.com/blog , and rewriting should normally rewrite article to www.mysite.com/blog/categorie/this-is-a-pretty-article but instead it rewrite to www.mysite.com/blogcategorie/this-is-a-pretty-article, as you see, it strip the tag between blog and categorie, wich is not suitable.

The rewriting rules inside web.config are pretty straight forward, taken from auto-generated WordPress Permalink section :

    <rewrite>
    <rules>
            <clear />
            <rule name="wordpress" patternSyntax="Wildcard" stopProcessing="false">
                <match url="*" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php" appendQueryString="true" />
            </rule>
    </rules>
</rewrite>

I've been losing allmost by whole day on this, so I tough asking for it might be a good idea…

Anybody already had that kind of trouble with wordpress on IIS?

Thanks in advance

Best Answer

I think your problem is a pure WordPress settings issue. The rewrite rules from your post are only important for incoming requests. I.e. they rewrite the URL from an incoming request to the index.php page. They are of no importance for any URL's generated by WordPress and that's clearly where your problem is.

My guess is that you have not properly configured Settings -> General -> WordPress address (URL) and Settings -> General -> Site address (URL). Both should be set to http://www.mysite.com/blog (without a trailing slash). If you use custom permalinks (Settings -> Permalinks) your should leave out /blog in front of it. WordPress will add that automatically as is also shown on that page.

When configured like this, it should work.