URL rewriting in Blog Engine.NET

was just looking for a way to get short URL’s for my blog, I used some extensions, some URLrewriter.NET but still not able to get this work. So I drop an e-mail to Scott Hanselman and was waiting for his response. If you look at Scott’s blog you will see that he has very simple URL for his blog posts which eventually get his posts higher ranks on search engine indexing. What I have found so far is that if you have a simple URL the search engine will crawl that page during indexing and your page is on the top of the search results or if it is not on the top then it must be at least on the first page. Remember search engine crawlers will avoid crawling pages that do not have a simple URL, like if your page has a query string it won’t be get crawled by the search engine crawler.

The URLRewriter module in BlogEngine didn’t seems to be working for Posts. I want to have simple SEO friendly URLs like http://www.midnightprogrammer.net/post/Windows-7-Logon-Screen-Changer.aspx and not http://www.midnightprogrammer.net/post/2010/05/30/Windows-7-Logon-Screen-Changer.aspx But there is no way to do this until I hook into BlogEngine.Core.dll.

Open the whole solution in Visual Studio and open Post.cs file and navigate to the RelativeLink property in Post.cs file and change with the below code:

public string RelativeLink
{
    get
    {
        string slug = Utils.RemoveIllegalCharacters(Slug) + BlogSettings.Instance.FileExtension;
        if (BlogSettings.Instance.TimeStampPostLinks)
            return Utils.RelativeWebRoot + "post/" + slug;
        return Utils.RelativeWebRoot + "post/" + slug;
    }
}

Recompile your DLL and place in bin directory in your blogengine root folder. Now you will have short URLs which do not have any date stamp. Having short URLs for all your posts doesn’t affect the posts with old URLs that most of the people have bookmarked on their blogs or on social bookmarking sites. Hope this helps.

comments powered by Disqus