-1

I have a few websites that could benefit from some URL rewriting. I understand that a map file is needed, but as the data is dynamic, is there a way to call from an SQL database instead of a static file?

Using ISAPI Rewrite via IIS7

eg unfriendly - www.domain.com/products.asp?prodID=1 Friendly - www.domain.com/products/Apples

Any examples or pointers would be apprecaited. thanks in advance. C :-)

2 Answers2

0

one possible solution is to do this with a custom 404 handler... when the user hits /products/apples the 404 handler picks it up, does a database lookup and matches that back to prodID=1 and displays the right content.

it's not particularly elegant but it works (I've used it in the past and as long as you remember things like returning the right HTTP response headers for content vs a genuine 404 you should be okay)

Most folks end up using something like ISAPI_Rewrite

Offbeatmammal
  • 7,970
  • 2
  • 33
  • 52
0

Create a new .asp page that retrieves the product using the url name of the product. The new page should be similar to your existing products.asp page but instead of getting the product using the id, you are getting the product using the unique url name.

RewriteRule ^products/(.*)$ /productfromurlname.asp?urlname=$1 [NC,L]

This way:

/products/apples --> /productfromurlname.asp?urlname=apples
/products/oranges --> /productfromurlname.asp?urlname=oranges
James Lawruk
  • 30,112
  • 19
  • 130
  • 137