WordPress Site in a Virtual Directory

Filed in Uncategorized Leave a comment

Recently we faced an issue with setting up the permalink on a word press site deployed over IIS7.

Actually there was a main site (like www.abc.com) and the wp site was setup as a virtual directory on that website (likeĀ www.abc.com/wp).

When we setup the permalink to post name (pretty permalink as said by word press) all the links on the site end up in the page not found error (404 error). The actual problem got identified when i looked at the URL Rewrite settings in the IIS for that virtual directory, there were many redirection rules appearing and those were defined on the root of the website and the redirection rule that was defined for the wp site was appearing at the bottom of the page. So I moved that rule to the top of all the rules and the problem got resolved.

Hope this will help someone as well, as we’ve spent 10s of hours to fix it with trying out multiple things.

———————–Updates: Nov-25-2011———————–

The actual reason was that the virtual directory’s web.config file was inheriting rules from the root site’s web.config. So the alternate is to add the “Clear” tag before any rules tag in the web.config file. Clear will remove the inheritance or rules for that virtual directory. Please see below:

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

, , ,