Change site collection URL in SharePoint 2013

Summary: This post describes the different ways to change the site collection URL in SharePoint 2013.

So, your manager/the business asks you to create a few site collections for some departments in your organization. You quickly spin up some site collections for them to use. After a few weeks, the business decides (of course) SharePoint is great, but the URL’s we chose weren’t all that great. Can you please change them?

There are alot of blog posts out there that describe the different possibilities in this scenario:
– Using backup and restore.
– A great article by Todd Klindt that tells you how to use the Copy-SPSite cmdlet to achieve the same goal but easier!

There is another (easier) way in some scenario’s in which you can change the site collection URL by just using 2 lines of PowerShell with only a second of waiting time!

The solution
Let’s get down to it.. I created this very nice Marketing site collection, using the url: http://sharepoint/sites/marketing. Now I would like to change this to http://sharepoint/sites/sales. Just use the following 2 lines of PowerShell code and you are done!

 $site = Get-SPSite http://sharepoint/sites/marketing
$site.Rename("http://sharepoint/sites/sales")

That is all.. try it out and see that your new URL is working, and the old URL is not working anymore!
*NOTE* Thanks to Jaymeson in the comments for pointing out an IISRESET is needed as well!

A little catch
There is a little catch to this. You can only use this to rename site collection URL’s that
– Use “Wildcard inclusion” Managed Paths.
– Are Host named site collections (In which case you could also use Set-SPSiteURL)

You can’t use it to change http://sharepoint/sites/marketing to http://sharepoint/marketing (Even if the Explicit inclusion managed path exists).

Hope this helps anyone out there!

10 thoughts on “Change site collection URL in SharePoint 2013

  1. It tells me to empty Recycle Bin first.
    Exception calling “Rename” with “1” argument(s): “Cannot rename a site collection with recycled items. Empty the site recycle bin of site collection https://share.test/office/test and retry.”
    At line:1 char:1
    + $site.Rename(“https://share.test/office/one”)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

  2. Nico – So, is there no way to change “http://sharepoint/sites/marketing to http://sharepoint/marketing (Even if the Explicit inclusion managed path exists)?” I just spun up a site with /sites/ and wildcard inclusion managed paths then realized that I wanted to ensure Global Navigation would work. The best way to do this seems to be reusing terms in site collection navigation which requires… Explicit Inclusion managed paths.

    Hoping not to have to blow away all my work.

    • Hi Michael,

      I don’t think that scenario is supported by the rename function. However, you can still create a backup of the site collection and restore it to the location of your choice. Or you could use the Copy-SPSite cmdlet.

      I hope this helps.

      Regards,

      Nico

  3. Warning! I tried this with a special character in the URL “ü” and this made my site unreachable. Even worse I can’t find the site with powershell as well! In the Admin Control Center I see the site collection but it looks messed up no information is displayed. I know the site is still on the database since the Sitecount on the DB is higher than the amounts of sites I get with the command get-spsite. Any advice how I can change the URL back?

    • Hi,

      You can do that by changing the URL of the Web Application. This can be done by changing the Alternate Access Mappings. Make sure you update your DNS as well.

Leave a Reply

Your email address will not be published. Required fields are marked *