tags:

views:

28

answers:

2

Here's the scenario. I'm using a url rewriter that allows me to specify patterns and redirects if they match, pretty typical stuff.

I'd like to add a new rule to the bottom of my rules that is a catch all, but only to a degree. I don't want it catching anything that ends in .aspx or is just plain empty.

I have this so far:

(.+)(?!\.aspx)

My thought was capture at least one or more characters unless it ends in .aspx.

So default.aspx should not match but default will. Product.aspx will not match but product will.

This also failed:

 (\w+)(^\.aspx)

Any help would be appriciated.

A: 

Maybe two simpler rules?

\.aspx$      # handle explicitly
.+           # catch all
Nathan
I need it to work on a single line, it needs to be a rule that says, if they type anything without a .aspx on it, ship it to my contentpage.aspx.
Joshua Belden
What about images and other non-aspx files?Or, the standard way of handling that would be by rewriting your 404 page to redirect to contentpage.aspx. In Apacheland it'd be this directive: ErrorDocument 404 http://my.url/contentpage.htmlBut in IIS I think you can customize the errors through the Properties panes.
Nathan
+1  A: 

Try this regular expression with a negative look-behind assertion:

(.+)(?<!\.aspx)$
Gumbo
+1 I was just reaching for MRE :P
Aiden Bell
Nice, it was the stinkin dollar sign at the end. I stumbled upon negative look behinds but thought it wasn't going to work. Thanks man.
Joshua Belden