iFinity Blogs 

Regenerating DotNetNuke Blog Permalinks when changing to Friendly Urls

Jun 8

Written by:
Wednesday, June 08, 2011 2:46 PM  RssIcon

Recently I’ve been doing a lot of work around installing the Url Master module and updating blog posts in the DotNetNuke Blog module.  Whenever you install the Url Master module and activate it, one of the more important changes it makes is to remove the /tabid/xx from all Urls on the site, including those in modules which add extra information to the Url.  The Blog module is a perfect example of this – even with the standard DotNetNuke Friendly Url Provider set to ‘humanFriendly’, the blog posts will still take the format of http://example.com/blog/tabid/xx/blog-post-title.aspx.  The reasons for this are deep and I’m not going to go into them here.

However, once you install the Url Master module or any other Friendly Url provider which removes the /tabid/xx from the Url, the blog module Urls do not change.   Worse, if you use the Url Master module ‘redirect unfriendly urls’ option, you end up with a 301 permanent redirect loop – which, if you use Chrome or Firefox, you are told about.  If you use IE (yes, even the latest version) you end up staring at a page that never seems to load. 

Permalinks – they’re very permanent

This is because the DotNetNuke blog module uses what it calls a ‘Permalink’.   This is the canonical Url for the post, and it is saved in the database along with the rest of the post details.   With the SEO options switched on in the Blog module, if you request a post without using the ‘canonical’ or ‘permalink’ Url, then you will get redirected to the correct Url.  So far, so good.

Part of the installation procedure for activating the Url Master module is, if you use the Blog module, to go into the Blog Module ‘Module Options’ page, and click on ‘Regenerate Permalinks’.   What this does is go through each and every post in the blog, and call the current Friendly Url Provider with the details of the blog post.  The results from that call are then updated into the ‘permalink’ field, and thus, a new canonical Url for the post is created.

Again, so far, so good.  At this point most people are happy and on their merry way to other tasks, like deleting a ton of spam comments.

The Problem

The problem is if you (like me) start to fiddle further with your Urls.  You might change the name of your Blog Page, or move it around.  Or perhaps change the title of your post.  Or get rid of the current Friendly Url Provider you have and go back to the standard DNN one.

At this point, any of those changes will need you to click on ‘regenerate permalinks’ again to keep the blog module in synchronization with your site, in terms of the Urls used.

However, if your current permalinks don’t include the /tabid/xx path, then you can click on the ‘regenerate permalink’ button until you wear out your mouse button, but it will never update them.   

The reason for this is a bit of code which only allows the module to update the permalink if the current link contains /tabid/.  Which, when you’ve changed the friendly url provider, it may well not.  I think this is a bug, and I’ve logged it on codeplex here : DotNetNuke Permalink Regeneration Bug.  Basically, once you’ve removed the ‘/tabid/’ pattern once, your links are stuck in a loop and can’t be fixed.

The Workaround

But, if you’re in this situation now, you need a fix right this minute. So here’s the workaround.

The piece of code that I think doesn’t work correctly also tests for a specific condition – an empty permalink value for the blog post.

That should give you a clue – the key to generating new permalinks is to ensure that there are no existing ones.

Armed with that knowledge, here’s what you do:

1. Run this piece of Sql in your Host->Sql page:

update {databaseOwner}{objectQualifier}Blog_Entries

set Permalink = ‘’

where blogId = x

You need to substitute in your Blog Id for x.  This is easy to find – just click on the link for the blog and it will show the blogId in the Url.  Note that once you have run this Sql, your module isn’t going to work too well.  So quickly go to step 2.

2.  In the View_Blog module, drop down the ‘Module Options’ menu and then click on ‘Regenerate all Permalinks for this Module’.  This will run the permalink regeneration routine, but this time, because there are no permalinks, these will be regenerated from scratch and your module will have the right links for all blog posts.

3.  Pat yourself on the back, you’ve fixed an issue.

Let me know via the comments if you’ve tried this and it didn’t work, or if you have any other feedback in this area.

Tags:
Categories:
Location: Blogs Parent Separator Crafty Code

4 comment(s) so far...


Gravatar

Re: Regenerating DotNetNuke Blog Permalinks when changing to Friendly Urls

Thanks! This came in handy. If you're like me, you ran into this issue when you launched your website, and had to change the portal alias from a development URL to a live URL. Or, maybe you're simply changing the domain name and everything else is staying the same.

If that's the case for you, then you can accomplish everything in one step, avoiding the potential downtime (and uncertainty) between steps 1 and 2, skipping the need to regenerate permalinks.

Here's the SQL script:

UPDATE {databaseOwner}{objectQualifier}Blog_Entries

set Permalink = REPLACE(Permalink, 'www.olddomain.com', 'www.newdomain.com')

where blogId = x

I was a little skeptical about the "regenerate permalinks" link button because it wasn't doing ANYTHING when I clicked it. So, I was unsure it would actually regenerate the permalinks.

Hope this helps!

By Scott Michie on   Friday, June 17, 2011 2:12 PM
Gravatar

Re: Regenerating DotNetNuke Blog Permalinks when changing to Friendly Urls

@Scott - yes, that would work as well. My guess is that the same bug in the regenerate permalinks button was causing you grief as well. It is one of the perils of having a saved Url instead of a generated one. But there are other benefits to saving a permalink in terms of canonical Urls and performance. The tradeoff is that you have to have a very robust way of re-synching the permalinks to the latest and greatest version.

By Bruce Chapman on   Friday, June 17, 2011 7:53 PM
Gravatar

Re: Regenerating DotNetNuke Blog Permalinks when changing to Friendly Urls

I am running into a problem...I have both the News Article and Blog module plugins installed. If I enable the News Article Plugin, the regenerated blog links cause a 404 error. If I disable the News Article Plugin, the regenerated blog links are correct.

By Tony Carter on   Friday, December 23, 2011 8:21 AM
Gravatar

Re: Regenerating DotNetNuke Blog Permalinks when changing to Friendly Urls

@tony - do you have both module providers marked as not using the DNN Page path?

If so, this is probably the issue. Try marking one as including the page path and see if that fixes the problem. If not, let me know.

By Bruce Chapman on   Friday, December 23, 2011 8:43 AM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
Bruce Chapman
Hi, I'm Bruce Chapman, and this is my blog. You'll find lots of information here - my thoughts about business and the internet, technical information, things I'm working on and the odd strange post or two.

 

Share this
Get more!
Subscribe to the Mailing List
Email Address:
First Name:
Last Name:
You will be sent a confirmation upon subscription

 

Follow me on Twitter
Stack Exchange
profile for Bruce Chapman at Stack Overflow, Q&A for professional and enthusiast programmers
Klout Profile