Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / SharePoint

Change Site Collection URL in SharePoint 2010

0.00/5 (No votes)
30 Nov 2012CPOL 32.2K  
How to change the name of a SharePoint site in URL

Introduction

If you want to change the site name (i.e. http://myserver/sites/SiteName/) in the site collection URL, you can't use Site Setting or Central Administration. Unfortunately, the only way is backup the site, delete it and restore in a new site with the right name.

Background

In Sharepoint 2007, you can use the stsadm command to do this, but in SharePoint 2010 you can't do this. You have to use Windows PowerShell for SharePoint.

Using the Code

First of all, open SharePoint 2010 Management Shell, you can find it under Microsoft SharePoint 2010 Products in the Start menu.

The first step is backup the current site:

//
// Backup-SPSite http://myserver/sites/OldSiteName/ -Path C:\MySite.bak
// 

After that, delete the site using the following code:

//
// Remove-SPSite –Identity http://myserver/sites/OldsiteName/
// 

NOTE: This step is necessary only if you want to restore the buckup in the same server of the old site. You have to do this because after the restore, a lot of items (i.e. lists) use the same IDs of the original site.

Now you can restore the site in a collection with the right name:

//
// Restore-SPSite http://myserver/sites/NewSiteName/ -Path C:\MySite.bak
// 

History

  • 30th November, 2012 - Initial release

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)