using asp.net rewrite and wordpress permalinks

I have a site that uses asp.net and wordpress. The wordpress component is in a sub-directory called wordpress. It uses permalinks.

I also have an asp.net site that uses the site root directory as ist top level diretory.

The asp.net site uses some rewrite rules so i can access the .aspx pages without the .aspx extension. Effectively it adds .aspx to the page. This is the rewrite rules in the web.config file

<rewrite>
  <rules>
    <rule name="san aspx">
      <!--Removes the .aspx extension for all pages.-->
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="/*.png" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="/*.php" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="/wordpress/*.php" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="/webservice/*.asmx" negate="true" />
      </conditions>
      <action type="Rewrite" url="{R:1}.aspx" />
    </rule>
  </rules>
</rewrite>

this works fine for the asp.net pages.

However it also adds the .aspx extension to the wordpress pages. So if I have a page (displayed as a permalink) such as

/recurring-billing/

it looks for a page called

/recurring-billing/.aspx

If I turn OFF permalinks, the wordpress pages display correctly because the asp.net rewrite rule

<add input="{REQUEST_FILENAME}" pattern="/*.php" negate="true" />

correctly identifies the .php page and ignores the rewrite.

Question: what extra condition do I need in the asp.net rewrite rules so it does NOT add .aspx to a wordpress permalink.

Read more here: using asp.net rewrite and wordpress permalinks

Leave a Reply

Your email address will not be published. Required fields are marked *