Urlrewriting.NET help required

Izi

Izi

Soldato
Joined
9 Dec 2007
Posts
2,718
Really struggling with some rules I need to write.

Bascially I want /news/ to go to one page and /news/a-news-story to go to another.

<add name="News" virtualUrl="^/news/"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/News.aspx?s=/news/"
ignoreCase="true" />


<add name="NewsArticle" virtualUrl="^/news/([0-9]+)/([0-9]+)/([0-9]+)/(.+)/([0-9]+)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/ArticleView.aspx?s=/news/article/&amp;ArticleID=$5"
ignoreCase="true" />


these rules work independently but when they are both in they stop working. How to I fix this?
 
You can remove all the parenthesis from your patterns.

Also, place the the other way round. Rules have an order of precedence.. so your "/news/" rule is triggered by "/news/an-article-blah-blah" because it hasn't yet tried the other.

Or change your pattern to "^/news/$"
 
<add name="NewsArticle" virtualUrl="^/news/([0-9]+)/([0-9]+)/([0-9]+)/(.+)/([0-9]+)"

taking the brackets out of that broke it..

moving the order which they were in fixed the issue though.

what does the $ sign mean?
 
Back
Top Bottom