ASP.Net URLMappings

Alright, Still in process of tweaking my blogging tool, Europa, for SEO success. One of the points on the list from Chris was to make my URL's cleaner. Before today, I was using the standard querystring method of reaching pages. The problem with these, is that search engines have a hard time digesting them (Let alone humans.)

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:

The after effect of URLMappings is as follows:

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:

<?xml version="1.0" standalone="yes"?>
<urlMappings enabled="true">
   <add url="~/346/2007/9/27/Lucky-Man.aspx" mappedUrl="~/blog.aspx?bID=346&amp;Blog=Lucky+Man" />
</urlMappings>

 

Now, I reference URLMapping.xml from the Web.Config file of my website:

<configuration>
   <system.web>
      <urlMappings configSource="URLMapping.xml" />
   </
system.web>
</configuration>

 

 

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.


Tags: Technology, SEO, URLMappings, Microsoft, C#, ASP.NET, Europa, Blog, Visual Studio


3 comments

Nick Ashley said at 10/5/2007 12:58:19 PM...

Gravatar 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]"


Eric Downey said at 2/6/2008 8:09:29 AM...

Gravatar 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....


Josh Erickson said at 5/29/2008 4:04:27 PM...

Gravatar 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).


Post a Comment
(Click)
Name:  
E-mail:  
Website:
Are you human? (Type "yes".)  

Add Your Comment: