views:

314

answers:

2

Hi there, I was wondering if it is possible to do URL Rewriting with Classic ASP when you do not have access to IIS to make any rewrite changes?

We have an online shop where products are typically linked as /product.asp?ContentID=X but would like to have something more SEO friendly such as /product/unique-product-name

Unfortunately we are on a shared hosting platform and are current hosting provider is not willing to install additional components to their server in case they cause issues for others. :(

+2  A: 

Probably not.

You should, at least, alter IIS configuration for 404 pages, so you code could take control.

Rubens Farias
+1  A: 

I've done this. It's kludgy but workable.

As another commenter mentioned you can have a custom 404 page. You'll need at least a little cooperation from your hosting provider to alter IIS to send 404 errors to a custom page in your directory. They shouldn't have a problem with that; won't affect other users.

As far as I can tell, on your custom 404 ASP page, about all you really have access to is the original URL via Request.ServerVariables("QUERY_STRING")

You can then parse the contents of that out and redirect to whatever is needed with Server.Transfer (not Response.Redirect, because you want a seamless server-side redirect and not a client-side redirect)

Make sure you have a fall-though case to handle actual 404 errors too!

John Booty
I've also done this. It's lame, and you may need some workarounds in forms, but if there's no other way available, it works fine.
mgroves
mgroves, how'd you handle form POSTs?
John Booty
I've done it a couple ways, but I think the easiest way was to just use normal ".asp" URLs in your post attribute. I think you might also be able to pull it off by using server.transfer in your 404 trap.
mgroves