The code that follows takes a URL, finds the page type and ID in the URL and rewrites the URL to serve up a page that takes Querystrings as parameters.
The original URL would looks something like this: http://www.site.com/List/Dotnet/102938/Rewrite_URL_Method.aspx
The following method would extraxt the ID (102938 in the above URL) and the type (if it is either "LIst" or "Details") and serve up the appropriate page -- in this case "content_list.aspx".
Note that the "Dotnet" directory and the "Rewrite_URL_Method.aspx" page referenced in the above URL are completely ignored as there is neither such a directory or page by those names.
If bList Then file &= "content_list.aspx" ElseIf bDetails Then file &= "content_details.aspx" End If
Context.RewritePath(file & "?id=" & key)
End If
End Sub
An alternative to having the ID in the URL would be to query a database. You can provide a "filename" and search a database based on this faux filename assuming, of course, that these names are unique.
Other more complex samples for Rewriting URLs are readilly found on the Internet, usually involving creation of a module.