Results 1 to 3 of 3

Thread: url rewrite regex - root files only

  1. #1
    Fanatic Member
    Join Date
    Nov 00
    Location
    Minnesota
    Posts
    798

    url rewrite regex - root files only

    I am using url rewriting rules in my web.config and have it working but today I added a rule in a folder but my primary rule keeps overriding.

    Web.config
    Code:
    <rewriter>
         <rewrite url="~/folder/*_a_(.+).aspx" to="~/folder/index.aspx?id=$1" />
         <rewrite url="~/*_a_(.+).aspx" to="~/listing.aspx?id=$1"/>
    </rewriter>
    Usage:
    www.domain.com/topic_a_1.aspx -> This would load listing.aspx?id=1 which is great.

    www.domain.com/folder/newtopc_a_2.aspx -> This is also loading listing.aspx?id=2 but should be loading index.aspx?id=2

    I believe I need to change the second rule from *_a_... to something like [^\/]_a_.... but that doesn't work.

    Anyone know what I can do so the second rule doesn't override my sub folder rules?

    Thanks.

  2. #2
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,738

    Re: url rewrite regex - root files only

    Hello,

    Just to confirm, if you remove this rule:

    Code:
    <rewrite url="~/*_a_(.+).aspx" to="~/listing.aspx?id=$1"/>
    Does the other rule work as expected?

    Gary

  3. #3
    Fanatic Member
    Join Date
    Nov 00
    Location
    Minnesota
    Posts
    798

    Re: url rewrite regex - root files only

    Good question. I will have to test it out after hours or on development site since it's the live rewriter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •