MVC3 + WordPress IIS Url Rewriting Rules MVC3 + WordPress IIS Url Rewriting Rules wordpress wordpress

MVC3 + WordPress IIS Url Rewriting Rules


Figured it out on my own. Regex is probably one of the most powerful YET complicated / confusing technologies there is. But in this case the patternSyntax flag was set to Wildcard, not Regex, which caused my confusion. Hope this helps someone else out there! =]

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


This is one of the very few posts anywhere that talks about making WordPress and ASP.NET coexist nicely in an IIS setup. So Kudos for that.

I was thinking to post this as comment to either your original question or the answer, but I chose to write an "answer" only because this is an honest question and I need some formatting capabilities.

I have multiple ASP.NET apps running on by site. In particular the root website is running an MVC4 app.

Since I cannot have WordPress installed at the root, my plan was to have it on its own app folder http://mydomain.com/wordpress/ and then have a URL-rewrite rule that to do the following (using peudo-code):

blog.mydomain.com/{path} --> mydomain.com/wordpress/{path}

I've only caused a mess with this approach and have not been successful using pretty permalinks, sometimes getting into redirect-loops and other times breaking links to .css files, admin pages, etc...

Have you ever given this a thought, i.e., having wordpress as a subapp instead and do sub-domain URL-rewriting?!?!


I had a similar situation but I had no need to edit my web.config file. Instead I followed instructions here at https://wordpress.org/support/article/giving-wordpress-its-own-directory/ where this is documented.

At point 7) within Moving WordPress process to a subfolder Method II (With URL change) you find options for a IIS installation.