1

I have a folder with an image in it called:

/products/12345/800.jpg

where 12345 = a database id and 800.jp is a 800 pixell wide image.

I want to create a nice url like this:

/products/12345/800/this-is-a-nice-readable-url.jpg

In IIS7, I have created the following regular expression:

(.*)/products/([0-9]*)/([0-9]*)([/\-\.0-9a-z]*)

I get a match when I test against the following URL:

http://localhost/products/12345/800/this-is-a-nice-readable-url.jpg

So I created the following rewriteurl:

{R:1}/products/{R:2}/{R:3}.jpg

But that does not seem to work. I thought that the above rewrite would get me to:

http://localhost/products/12345/800.jpg

But it does not. So I guess my issue is that I have succeeded in creating a match, but I have failed and replacing the source with the target.

How can I make this rewrite work properly.

Ralph M. Rivera
  • 769
  • 3
  • 12
  • 25

1 Answers1

1

The url part which is used to match your pattern doesn't contain leading /, so you are indeed very close to success, try to use this pattern:

(.*/)?products/(\d+)/(\d+).*

and rewrite:

/{R:1}products/{R:2}/{R:3}.jpg
Tomek
  • 3,267
  • 2
  • 22
  • 23