I've explored multiple ways to rewrite URL's for my website and since I'm in a shared hosting environment most of them just won't work. Theres the ISAPI filter that you need to install on the web server to make it work. If you have your own server this isn't an issue, however if you are like me and use shared hosting you'll know you can't do that. Then there's the ASP.Net way or URL rewriting.... um yeah, that doesn't cut it either. So after much laboring I found URL Rewriting.Net. It's a simple .DLL that you include into your project and then add some stuff to your web.config and presto, you're done. So here is the code you put into your web.config:
<configSections> <section name="urlrewritingnet" restartOnExternalChanges="true" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/> </configSections> <urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" compileRegex="true" xmlns="http://www.urlrewriting.net/schemas/config/2006/02"> <rewrites> <add virtualUrl="^~/(.*)/ProductInfo(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/ProductInfo.aspx?ProdID=$2" ignoreCase="true"/> <add virtualUrl="^~/(.*)/Article(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Article.aspx?AID=$2" ignoreCase="true"/> </rewrites> </urlrewritingnet>
It may look confusing but the meat and potatoes is the "add virtual" part of the code. The tilde (~) means use site root, then a "/", now a wild card for some fictitious directory, another "/", the name of the page and bang it works. To learn more about this control and for downloads Click Here
Hope this helps someone, I know it's helped me.