Will "the Mighty" Strohl

Updating DotNetNuke Blog Permalinks for URL Master

If you’re using the URL Master module from IFinity, chances are that you are also using the extension-less URL pattern like you see on my site.  This is a great way to shorten your URLs for a more SEO-friendly impact when search engine spiders crawl your site.  It also removes the TabID from the URL, which also has a meaningful impact on SEO – not to mention making the URLs more human-friendly.  This is sometimes more important than the SEO benefits.

By default, the DotNetNuke® Blog Module generates a URL that looks like the following URL:

http://www.domain.com/PageName/tabid/123/EntryID/123/Blog-Title.aspx

This isn’t a horrible URL structure, but it leaves plenty of room for improvement.  That pesky TabID needs to go.  This is done automatically by URL Master.  It also gets rid of the .aspx for you with a simple setting checkbox.  You really cannot get rid of the EntryID without modifying the Blog Module code.  You could get rid of the PageName too, but you might not even have to deal with it if your blog module lives on your home page.  For me, the optimal URL would look more like this:

http://www.domain.com/PageName/EntryID/123/Blog-Title

You may notice that I already have that done.  Well, URL Master made its job easy, but I still had the old URLs rendered in the mark-up of the blog module.  Meaning, when you hovered over the blog links, you saw the original URL format, and your web browser goes to that same URL when the link is clicked.  Luckily, URL Master will perform a 301 redirect, so the search engines are covered, but it would be even better for the search engines, and even better for your visitors who might create their own links to those blog links in your page.

How do we fix this?  My first instinct was to regenerate the permalinks in the blog module, in its Blog Settings.  This didn’t have the intended effect.  So, I resolved to having to manually update the permalinks.  It’s unbelievably simple to make this update.  You can do it in one query, but I have it broken down into two queries for illustration.

PLEASE NOTE: These updates have an irreversible effect on the database. It is suggested that you try this on a staging site first, and backup your database prior to executing these queries.

First, remove the TabID from the URL using this query (replace 123 with the appropriate tabid):

   1: UPDATE {databaseOwner}[{objectQualifier}Blog_Entries] 
   2: SET [PermaLink] = REPLACE([PermaLink],N'/tabid/123',N'');

Second, remove the .aspx extension using this query:

   1: UPDATE {databaseOwner}[{objectQualifier}Blog_Entries] 
   2: SET [PermaLink] = REPLACE([PermaLink],N'.aspx',N'');

If you want to see the effects you just had on the database, just run this query:

   1: SELECT [BlogID],[EntryID],[Title],[PermaLink]
   2: FROM [dbo].[Blog_Entries] 
   3: ORDER BY [EntryId] DESC;

I added the databaseOwner and objectQualifier tokens in the previous code snippets so that they could be run in the SQL Module.

That’s all there is to it.  Once your cache refreshes, all of your blog URLs should be rendered in the new SEO-friendly format.



blog comments powered by Disqus