I just installed IIS Url Rewrite 2.0 on my IIS Server and I'm having a bit of trouble getting some of my rewrites correctly executed. Here's my trouble:
I want all my files to be rewrittin to: welcome.aspx > welcome/, about.aspx > about/ etc. to achieve that I'm doing this:
<rule name="Remove extension with slash" stopProcessing="true">
<match url="(.*)/" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" appendQueryString="true" />
</rule>
So far that's working.. but I also have some querystring functions on default.aspx I want to be executed, when I run a URL like this: mysite.com/logout/ which really is mysite.com/default.aspx?action=logout due to this rule:
<rule name="Friendly URL" stopProcessing="true">
<match url="(.*)/" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="default.aspx?action={R:1}" appendQueryString="true" />
</rule>
But it wont execute the second rule because it will look for the logout.aspx file which does not exist, only in form of a querystring function in my default.aspx
Any way I can achieve both?
::::::::::: EDITS ::::::::::::
Ive been trying all day now.. I got pretty close with the following setup:
<rule name="Remove ext" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}.aspx" matchType="IsFile" negate="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" appendQueryString="true" />
</rule>
<rule name="Default actions" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="default.aspx?action={R:1}" appendQueryString="true" />
</rule>
<rule name="Other files with querystrings" stopProcessing="true">
<match url="^([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx?action={R:2}" appendQueryString="true" />
</rule>
Almost everything works
user.aspx > user
default.aspx?action=logout > logout
user.aspx?action=comments > user/comments
Only thing messing it up is if I add a slash after user ie. it will respond to the default.aspx rule and act as a querystring.. which is not intented.. Any clue?