II7 Rewrite Issues - excluding pages
Question
Hey all, I've got a question about IIS7 rewrite.
I'm wondering if there is a way to set conditions for re writing urls. I'm wanting to rewrite:
to become
http://www.domain.com/username/
I also have
http://www.domain.com/article.aspx http://www.domain.com/login.aspx
and I want those to become
The issue I'm having is that if I set up the rewrites for username the rewrites for article and login break.
I need to somehow exclude those from the username rewriting so that they can be handled on their own.
Here is my current code, im rewriting the usernames to /user/username at the moment:
<rewrite> <rules> <rule name="Rewrite user accounts2"> <match url="user/([_0-9a-z-]+)"/> <action type="Rewrite" url="user.aspx?id={R:1}"/> </rule> <rule name="Rewrite user accounts"> <match url="user/([_0-9a-z-]+)/"/> <action type="Rewrite" url="user.aspx?id={R:1}"/> </rule> </rules> </rewrite>
Solution
If you add the article/login rule at the top and add stopProcessing="true" to it then you dont have to use conditions.
<rewrite>
<rules>
<rule name="Login" stopProcessing="true">
<match url="login/?"/>
<action type="Rewrite" url="login.aspx"/>
</rule>
<rule name="Article" stopProcessing="true">
<match url="article/?"/>
<action type="Rewrite" url="article.aspx"/>
</rule>
<rule name="Rewrite user accounts2" stopProcessing="true">
<match url="user/([_0-9a-z-]+)/?"/>
<action type="Rewrite" url="user.aspx?id={R:1}"/>
</rule>
</rules>
</rewrite>
PS. the questionmark makes the preceding character optional.