Thursday, December 29, 2011

Fixing Absolute URLs in Navigation

I worked on a project to migrate SharePoint 2007 to 2010.  The 2010 site has a different URL than the 2007 site and I found lots of links in the top nav and left nav that had absolute URLs instead of relative ones.  The absolute URLs were pointing back to the 2007 site.  I decided to go against the grain and just execute an update statement in the content database to fix this.  Alternatively you could go to Site Settings / Navigation Settings and fix this.

In my case the absolute URLs started with http://intranet.mydomain.com/ so I just wanted to convert to a relative URL.  Here's the SQL statement to convert the absolute URLs to relative ones (grab the characters after http://intranet.mydomain.com and the / character that follows):

UPDATE [Content_Database_Goes_Here].[dbo].[NavNodes]
SET Url = SUBSTRING(Url, 29, LEN(Url)-28)
WHERELEFT(Url, 28) = 'http://intranet.mydomain.com'

No comments:

Post a Comment