Domanda

We're migrating a site collection to a new farm (SP2010 to SP2010, same version). In the old farm, the site collection resided at the root of the web application (http://oldsitecollection/). As part of a new governance strategy, in the new farm it will be under a managed path (http://newfarm/sites/sitecollection).

Within the site collection is a blog site (./Blog). Within this blog, all the posts reference images using the absolute path "/Blog/Photos/imageexample.jpg". This absolute reference does not play nice in the new farm as instead of referencing "http://newfarm/sites/sitecollection/Blog/Photos/imageexample.jpg" it now references "http://newfarm/Blog/Photos/imageexample.jpg". The images do not appear as expected as the URL to their location is now incorrect.

Is there a way to update all the URL references at once? Maybe a tool or a bulk operation of some sort? We are currently considering either editing each post and image individually or writing a PowerShell/C# application to go through each item and update the URL.

È stato utile?

Soluzione

Not 100% certain this will work, but in theory it's sound and it's the first thing I'd try in this instance

  1. Backup the site collection using powershell.
  2. Restore the site collection to the new location.
  3. Update the ServerRelativeUrl of the blog web.
  4. Ensure you call the .Update() method of the blog web object

Edit: if you're looking to change Urls with an post body try something like this in PowerShell

$oldImagePath = "/Blog/Images/"
$newImagePath = "/sites/Blog/Images/"
$web = Get-SPWeb $webUrl
$postList = $web.Lists["Posts"]
foreach ($post in $postList.Items)
{

    $postBody = $post["Body"]
    $postBody = $postBody.Replace($oldImagePath, $newImagePath)
    $post["Body"] = $postBody
    $post.Update()
}
$web.Dispose()

Of course you'll need to fix up the list name and field name to match what they actually are but that should acheive the change you desire (or close enough that you can get there)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top