Change Host Named Site Collection Url

Previously (i.e. until SP2010) zones was applicable only at the Web App level. You can have up to 5 zones and thus five different urls.

With SharePoint 2013 this concept has been extended to the Site Collection level - but only to the Host Named Site Collections (HNSC). You can have up to 5 different URLs each associated with a zone for a single host named site collection. You can achieve this using the Set-SPSiteUrl PowerShell cmdlet.

Before RTM, SharePoint 2013 had the ability to have multiple URL's for the same zone. So you can have any number of URLs not just five. But this feature has been discontinued/deprecated since RTM. Here is a KB article endorsing this:

There are still some blog posts (link, link) which mentions that this is still possible - but its not.

OK. That's enough background I guess. Coming to the title of this post:

Since you cannot have multiple URLs for a single zone. Lets say you have a HNSC that was either built new or restored from an existing one. And now you want to change the URL for this HNSC and for that zone in particular. If the above feature was available you could easily add your required URL using the Set-SPSiteUrl cmdlet. But since the above feature doesn't exist anymore there is an easier way to accomplish this. You can use the SPSite.Rename method to change the URL of a HNSC to a new URL. Here is the PowerShell script:

$site = Get-SPSite -Identity https://contoso.old