views:

138

answers:

1

I'm using Intelligencia's UrlRewriter in my application and I'm having a problem where the rules I've setup appear to be stripping the + symbol from my url.

For example I want to have the urls /category/catname/+tag+tag but it appears to me as /category/catname/ tag tag

Does anyone have any ideas and is this down to my regular expression? I've tried it in regulator and it matches fine.

<rewriter>
  <rewrite url="^/content/(.+)$" to="~/page.aspx?name=$1" />
  <rewrite url="^/category/(.+)$" to="~/catalog.aspx?category=$1" />
  <rewrite url="^/product/(.+)$" to="~/catalog.aspx?product=$1" />
  <rewrite url="~/login/" to="~/login.aspx"/>
</rewriter>
+5  A: 

The reason why it is doing that, is because the "+" gets parsed as a space by the webserver before your rewriter actually get it. A litteral + is something that you can not use in an actual URL. If you want to use a + then you need to reference it as something like %2B: "/category/catname/%2Btag1%2Btag2".

Edit: Here is an example of URL encoding This illustrates a few of the characters you can not use, and how to encode them. If you are looking for more visual appealing characters for a URL, you can try "-" and "_" which are both valid, I'd suggest the "-". an example of the url would then be "/category/catname/-tag1-tag2".

stephenbayer
Nail on the head!
mspmsp
Thanks for the answer stephen, i'm using - to cover spaces in the category names so i'll have a think about this. But cheers for the answer.
dnolan