1

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.

Community
  • 1
  • 1
Christine
  • 59
  • 7

2 Answers2

1

Edit: I just thought of something... maybe the leading / shouldn't be there. You could try this:

([^/.]*)$

I'm also thinking, to pass querystrings through, you could possibly do this:

([^/.?]*)(\?.*)?$

...and use {C:2} in the replacement string to copy over the querystring.


The $ is important:

/([^/.]*)$

Then again, maybe not... it's really just a guess.

Olivier L.
  • 2,575
  • 1
  • 17
  • 11
  • I tried it with and without, so I think the problem lies elsewhere. I also realized that this whole idea is going to cause problems with any querystring-utilizing links I might use. What a headache. – Christine May 26 '11 at 17:20
  • For the querystring issue, you could simply add `?` in `[^/.?]`, as long as you always escape `/` inside the querystring. But yeah, this should be working... odd. – Olivier L. May 26 '11 at 17:27
0

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 :)

Christine
  • 59
  • 7
  • I also want to add that I've found a more elegant solution since. I use an IRouteHandler custom class with definitions in the Global.asax function void RegisterRoutes. If anyone comes across this looking for information and wants me to elaborate, just let me know. – Christine Feb 10 '12 at 15:59