A Developer
A Developer

Reputation: 1031

URL Rewrite in IIS7 Regular expression Pattern

I want a URL pattern for the following where :

this

http://www.test.com/xyz_number.jpg?vin=xyz&date=31052012

will be redirected to :

http://www.test.com/xyz/31052012/xyz_number.jpg

NOTE: Here xyz_number and date value are dynamic which will be changing for each request.

Upvotes: 1

Views: 1773

Answers (1)

Damian Powell
Damian Powell

Reputation: 8775

The following regular expression will perform the match:

^http://www.test.com/([^.]*).jpg\?vin=([^&]*)&date=(\d*)$

And the following expression will do the replacement:

http://www.test.com/$2/$3/$1.jpg

You don't say whether you're doing this in an ASP.NET HTTP Handler, or in an IIS module, but hopefully, this will give you a start.

Upvotes: 2

Related Questions