Search code examples
asp.netregexiis-7url-rewritingwildcard-mapping

Redirecting dynamic extensionless urls using urlrewrite wildcards


I have a dynamic list of "referrers", example ANN, BOB, ..., ZED. I want people who go to my url www.website.com/ANN, www.website.com/BOB, www.website.com/ZED to be directed to a special dynamically generated referrer page.

What I want to do is set up a URLRewriter rule on my IIS7 that will direct any page without a file extension to a /reroute.aspx which will handle generating the dynamic page. What I'm having a problem with is the regular or wildcard expression. I've tried

/*.*
*.*
/([^/.]*) 

The first two will work with /ANN if I use the "Does not match" setting, but then they also work on www.website.com/ which is the default address. The third one, Source, doesn't match /ANN according to the IIS expression checker.

I'd appreciate any advice any regex wizards could provide. Thank you very much.


Solution

  • In the end I just gave up trying to use such a simple link, and am using www.website.com/Refer/ANN

    The Query string I am using is refer/([A-Za-z0-9]+)$

    And Olivier was right, the $ is important :)