Last post Dec 09, 2008 10:36 PM by Bruce L
Dec 08, 2008 05:02 PM|dotnetnoob|LINK
Hi All: I have a legacy site in VBScript that rewrites friendly urls against a MSSQL lookup and server.transfers to a specific page (preserving the friendly URL).
I have IIS6 configured to pass 404s to this page, where I parse the QS in the 404 to get the "friendlyURL". Then I look up the URL in a dB, and depending on what I find, server.transfer to the appropriate page.
In this case, the "friendly url" is in the format "firstname-lastname", so my friendly urls will always be something like:
So I would parse out the substring, do a dB lookup, and then server.transfer to the page with a session-var holding the substring. I realize that using session vars in not the most scalable solution but it seems to work, and in this way I'm able to preserve
the original URL in the browser.
What is the best way to replicate this in IIS7? Can I use the URI rewrite module, or do I need to create my own module to do this? Are there any examples out there to do this?
Dec 08, 2008 09:15 PM|Bruce L|LINK
I think the IIS 7.0 rewrite module should work fine for you.
This is what you need to do at a high level
1) Create an aspx page that takes firstname & lastname as query string and perform the query
2) Create a rule that rewrite domain/firstname-lastname to domain/querypage.aspx?fname=[thename you passin]&lname=[lastname
Dec 09, 2008 09:48 AM|dotnetnoob|LINK
Thanks Bruce...but I'd like to try to preserve the original URL without sending a redirect to a different page back to the visitor ...that's what my original solution did and I need it to work the same way in .NET?
Dec 09, 2008 10:36 PM|Bruce L|LINK
That's exactly how URLRewrite will work
Your current pages are mysite.com/firstname-lastname
URL rewrite will represerve that and make a call to the query page behind the scene.