At first, this project of converting my links sounded very tedious. Initially I was thinking I'd have to write some elaborate routine on publishing an HTML page after writing a blog, similar to how blogger does it. Not only would I have to make an HTML page for each blog, but I would have to update the extra content (such as "last 10 blogs") in case I wanted to archive them, keep tabs on a main page, rss feed, etc etc etc. Didn't sound appetising at all.
Dissapointed and overcome by this method, I set on a search to find a nice and easy route. Lo' and behold, Microsoft never ceases to amaze me. URLmappings totally made my life easier. They allow you to set a sort of virtual path to your page, yet, still taking in querystring information.
For example, the link to my recent blog, "Lucky Man". It's original (and working) path is:
http://www.nicholasdavis.info/blog.aspx?bID=346&Blog=Lucky+Man
The after effect of URLMappings is as follows:
http://www.nicholasdavis.info/346/2007/9/27/Lucky-Man.aspx
Sweet, huh? All I had to do was create an XML file that is referencable to my web.config file. For example, I have a file called URLMapping.xml. This contains all my URL Maps. Example:
Now, I reference URLMapping.xml from the Web.Config file of my website:
That's all there is to it! So now when I save a blog, it opens the URLMapping.xml into a Dataset, quick add the links and save it back. Couldn't be easier.
posted at 9/30/2007
Gotta love URL rewriting. One thing you might want to look into is http://urlrewriter.net/ - it allows you to map urls using regular expressions, so rather then adding an entry for every page, you can make a rule that says "/post/[x].aspx" should always be rewritten to "/blog.aspx?id=[x]"
This is like one of the holy grails of website development! Can PHP or Java do this? I doubt it! I do a lot of development where the page is item.aspx?id=123. Now I get to say nuatical-bench-with-arms.aspx. The search engines are going to LOVE that! And I get to look way cool in front of the other developers who don't know about this...hehehehe....
Eric, PHP can do it, however the implementation is more "homegrown" and generally relies on the Apache mod_rewrite module (more akin to URLRewriter Nick A. was talking about).