Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > How to Rename SharePoint 2013 Site Collections Without Prayer or Sobbing
May 31
How to Rename SharePoint 2013 Site Collections Without Prayer or Sobbing

A couple of years ago I published a blog post, “Using Copy-SPSite to rename Site Collections in SharePoint 2013” to much fanfare and adulation. Okay, okay, adulation might be a bit strong (might) but it was a good find nonetheless. I thought I had reached the pinnacle of renaming Site Collections. I thought that my career was all downhill from here. I was going to be relegated to a has been. “Hey, remember that time back in ‘12 when I renamed a site collection without backing it up? “ I thought I was sunk.

Then the February 2015 CU came out.

Buried in all the bugs fixes and regressions was a cool new piece of functionality, the ability to rename site collections without backing them up or without copying them. Whatcho talkin’ ‘bout, Willis! In this blog post I’ll show you how to use it.


I know some of you have short attention spans, so I’ll throw out the PowerShell code to do this right away:

$site = Get-SPSite
$uri = New-Object System.Uri("")

To get 100% success I have to force the Content Database to refresh its site map with this:


and run an IISReset. The IISReset isn’t always necessary, but it’s good to plan for it. If you have a short attention span, you’re released now. Smile Go chase something shiny. Look! A rabbit! If you want to see the rest of the story, keep reading.

The Whole Story

When I first learned about this new method for SPSites, it was billed as a way to change path based site collections to Host-Named Site Collections (HNSC). Path based site collections are the ones we’ve been using since the beginning of time. They have the form of http://servername/managedpath/sitename. In my Redirection blog post the $V variable in the picture halfway down the page is the path. It’s the unique part between site collections. A path based site collection has a URL that looks like this: and

In both cases the host is the same, The thing that makes them unique is the path; /sites/foo and /sites/bar. When using host named site collections it’s the hostname that’s unique. Examples are: and

HNSCs are something that users have wanted since SharePoint came out. No one wants to type the full URL out, they all want to type something short. SharePoint 2013 has a soft limit of 20 Web Applications per farm, so that isn’t really an option. Previous versions of SharePoint offered functionality close to HNSCs, but it was never really usable. Thanks to Microsoft hosting SharePoint Online, and making heavy use of HNSCs, they’ve gotten much better in SharePoint 2013. I have no problem recommending them, in the right situations. The issue then becomes how to make the transition. Backing up your path based site collection, deleting it, then restoring into a HNSC works, sort of, but it becomes a real pain when working with large site collections. Also, deleting a site collection is scary business, and not for the faint of heart. Finally, it just seems unnecessary. All the juicy data is staying in the same place, why should we have to take it out just to put it right back in? Ain’t no one got time for that! February 2015 CU to the rescue.

Starting with build 15.0.4693.1001 we can change the URL of a path based site collection to that of a host named site collection. Here’s the whole process, with pictures:

First I created a site collection:

New-SPSite -Url -Template sts#0 -Name "Move me with PowerShell, Por Favor" -Description "Site moved with PowerShell" -OwnerEmail -OwnerAlias odfbdemo\todd


And threw it into a browser, just to make sure it worked.


Then I changed the URL in PowerShell:

$site = Get-SPSite
$uri = New-Object System.Uri("")


Then did a quick check to make sure it took:


It looks like it did. I’ll refresh my browser, just to make sure it’s really gone. It is.


Before my site collection can work at that hostname must resolve in DNS. I could have created a single A record to handle that. Instead, since I knew I’d be doing a lot of HNSCs, I created Wildcard DNS Record. That will cover all hostnames at that don’t already have a record in DNS. After I made the DNS record I pinged it just to make sure it was working. If you try to ping the site up in your browser before you make the DNS change, you might have to restart your browser for it all to work. Browsers have been known to cache an IP address from time to time.


With DNS squared away, let’s go back to the browser and try to load it up.


Que up the sad trombone. Sad smile Turns out this was easy enough to fix. We need to run the RefreshSitesInConfigurationDatabase method on the content database our newly renamed site collection.


In a couple of cases during my testing I also had to throw in an IISRESET to really clear up the errors. After that, success was mine!


One of the February 2015 CU KB articles mentions the new renaming functionality, but only mentions it in the context of going from path based to HNSC. That alone is impressive enough, and I could have stopped there. But I didn’t. I also tested this going from path based site collection to path based site collection. I must have eaten my vegetables that day because it worked. I used this PowerShell command to create the source path based site collection:

New-SPSite -Url -Template sts#0 -Name "Move me from one path to another" -Description "Please work, please work" -OwnerEmail -OwnerAlias odfbdemo\todd

I made sure it worked in Internet Explorer, then I ran the following PowerShell to rename it to

$site = Get-SPSite
$uri = New-Object System.Uri("")

It looked like this:


Then I fired it up in Internet Explorer at its fancy new URL:


I hate to brag, but it worked. Smile

It merits further testing, but on the surface it looks like it’s possible to rename path based site collections to new paths, or HNSCs.

If you try this, let me know how it turns out.




How about from HNSC to path based?

Thanks Todd, this post is handy!

Do you know whether we can use it to change site collection from HNSC to path based?
 on 5/31/2015 10:07 PM


What about O365 though?
 on 6/1/2015 2:20 AM

You'Da Man!

Outstanding Work as Always!!  OK, I know the check cleared before I posted this !

Kidding aside, this will come in very handy as we start a VERY large migration from 2010 to 2013 and all of the pre-cleanup work that has to be done.
 on 6/1/2015 5:02 PM

MSDN documentation

Thanks for the article Todd. It's interesting that the MSDN documentation for that Rename API says "You CANNOT use the Rename method to convert a host-header-named site collection to a path-based site collection and vice versa." when the KB article that comes with the Feb 2015 CU says it CAN be used for that purpose.

We'd have to try it out and bug Microsoft to update its documentation.
 on 6/1/2015 6:19 PM

Not working

I tried to rename a root site collection to a path-based site collection and got the following error:

Exception calling "Rename" with "1" argument(s): "Only host part for a host header site collection or the last segment after a wildcard managed path of a site collection Url can be renamed. http://my-web/sites/newsite is an invalid
new Url for the site collection at http://my-web."

Has the functionality changed? I just installed August 2015 CU. The web application is a HNSC for http://my-web
 on 9/4/2015 12:49 AM

Simple steps for Host Named Site Collection change

"Not working" - maybe give Todd the full command you ran which might help him more - he's a smart dude.

As for my situation - thankfully since 2008 onwards in our SP enviro we only used Host Named Site collections so we've been living the good life for some time now.

As for the command I just use the following from a SharePoint Command Line (of course) to rename a HNSC from one name to another:

set-spsite  -identity "oldurl" -url "newurl"

set-spsite  -identity -url

You can do an iisreset or just an app pool recycle on the webapp that site is contained in and your new site should be renamed.

Using version: 15.0.4569.1000 of SharePoint

Thanks for the post Todd - informational and humorous
 on 9/4/2015 1:43 PM


Is there any new information?

Exception calling "Rename" with "1" argument(s): "Only host part for a host header site collection or the last segment after a wildcard managed path of a site collection Url can be renamed. http://my-web/sites/newsite is an invalid
new Url for the site collection at http://my-web."
 on 10/2/2015 11:34 AM

Doesn't seem to work

according to the script everything works - but when I go to the new URL the page tries to load and then I just get the:

Sorry, something went wrong

and a correlation that doesn't exist.
 on 12/21/2015 5:21 PM

Rename HNSC

I already have a HNSC and would like to rename it. How should I do that?
 For example I created a HNSC with name and now I would like to rename it to

How should I do that?

Any clues
 on 3/3/2016 4:42 PM

How to rename HNSC

This is for the person who posted on 3/3/16 at 1642

use set-spsite -URL http:/
 on 7/5/2016 12:50 PM
1 - 10Next

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.


Body *

Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person


Want a message when I reply to your comment? Put your Twitter handle here.