David
David

Reputation: 106

Regular expression for IIS URL rewrite

I have a slightly unusual requirement for URL rewrite. I have a folder called brand and I want to redirect any requests outside of the brand folder to the brand folder but any requests inside the brand folder to be left alones.

So for example, if somebody requests the following URL:

www.test.com/a-folder/a-file.aspx

They are redirected to:

www.test.com/brand/

and see this in the browser, However if they choose:

www.test.com/brand/a-second-file.apsx

They see the a-second-file.aspx in their browser and are not redirected, because they are already in the Brand folder.

Can anybody help with the Regex I need to put into IIS

Upvotes: 0

Views: 150

Answers (1)

David
David

Reputation: 106

I've been able to figure this out on my own.

^(?!brand).*

The regex above seemed to work great!

Upvotes: 1

Related Questions