Link to home
Start Free TrialLog in
Avatar of ctudorprice
ctudorprice

asked on

Dynamic URLs to Static?

Hi
I want to be able to convert my dynamic links (i.e. http://www.mysite.com/products/product.aspx?ID=145) to static URLs (i.e. http://www.mysite.com/products/products/ID/145, or http://ww.mysite.com/products/145.htm) or something similar that will get indexed by the search engines, obviously without actually producing static pages for all of the produts.
Is there any easy way of doing this? I've seen some ISAPI products that seem to suggest that they do this... My site is hosted elsewhere, so I am not sure I can install ISAPI or other (non ASP.NET) solutions.
Anyone have any tricks/tips?
Thanks....
ASKER CERTIFIED SOLUTION
Avatar of ovalsquare
ovalsquare

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ctudorprice
ctudorprice

ASKER

Thanks, Ted. MSDN: Why use a few words when a few thousand would do? I hate the Microsoft msdn articles. I find them but turning all the background info into a simple, implementable solution is always difficult. (That's why I come to EE for quick, simple answers).
Here's what I did (simplified)... In the global.asax.vb:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim incoming As HttpContext = HttpContext.Current
Dim oldpath As String = incoming.Request.Path.ToLower
if oldpath="/product/myproduct.aspx" then
   incoming.RewritePath("/products/productlister.aspx?id=1")
end if
end sub
Sounds good ctudorprice. Nice summary ;-)

Hopefully you don't have reams of code to cover all your pages - you could modify the above so that it just parses it all together: i.e. productlister1.aspx, which would cover all pages with less code, but if you've just got a few pages, much nicer result.

Ted
Hi ovalsquare,
the solution I implemented does actually parse the inbound URL...
One thing I was hoping to do was to be able to use directories (i.e. http://www.mysite.com/product/1/) but it appears that the server looks for a default document in that dir before the Application_BeginRequest fires. So now, I have to code the URLs as http://www.mysite.com/product/1.aspx for the Application_BeginRequest to fire. Am I missing something?
So you were planning on putting one document per directory? How about posting your code, then I'm not barking up the wrong alley.

Ted