If you’re using host named site collections in SharePoint 2013 and have set an SPSiteURL in order to map a site collection to a different zone, you may have noticed when you backup that site from one farm to another farm, the default zone moves correctly to the destination farm, but any other zones continue to contain the url from the original source farm. Usually this presents it self as the site working when using the Default zone, but getting a pretty 404, when using the alternate zones. (Users love to use alternate zones). 🙂

lego404

(Best 404 eva!)

Let say you moved a site collection called https://myweb.contoso.com/sites/teamA and needed to move it to a staging farm, so you restored it at https://myweb.stg.contoso.com/sites/teamA
The default zone url is https while the intranet zone is http.

Powershell: (run Get-SPSiteURL against the Top Level Site Collection (Root Site) using the Default zone URL)
Get-SPSiteURL -Identity https://myweb.contoso.com
E.g.
Source Farm Top Level Site Collection
Url Zone
https://myweb.contoso.com Default
http://myweb.contoso.com Intranet
Destination Farm Top Level Site Collection
Url Zone
https://myweb.stg.contoso.com Default
http://myweb.stg.contoso.com Intranet
All the site collections get the Default and Intranet Zones from the Top Level Site Collection.
Now if you run Get-SPSiteURL against the actual site collection you just restored
E.g. Get-SPSiteURL -identity https://myweb.stg.contoso.com/sites/teamA
You’ll see the following.
Url Zone
https://myweb.stg.contoso.com/sites/teamA Default
http://myweb.contoso.com/sites/teamA Intranet
Notice the Intranet Zone in invalid. If you’re on the source farm, you can’t hit the site http://myweb.contoso.com/sites/teamA because that URL is technically not registered to anything in that farm. I’m not sure if they correct term is orphaned, but that’s the term I’ll use. (because reasons)
If a user were to try and access http://myweb.stg.contoso/sites/teamA it was also fail to find that site. even though http:// for any of the other site collections would work just fine.
So how do we fix this issue?
First thought would be to simply remove the invalid Zone from the newly restored site collection by running.
But you’ll get an error because 1. This url is really not mapped anywhere in this farm. (Orphaned) and because 2. you can’t directly modify a zone of a site collection except by modifying the Top Level site collection zone and it cascading down to all the other site collections zones in that host name.
So unfortunately, we need to get the invalid URL added to our top level site collection zone. This means we need to remove our current top level site collection zone for Intranet. *(Note: this will cause this zone to stop working on all the site collection under this host name group, not just the top level)
remove-SPSiteURL -url http://myweb.stg.contoso.com
This removes the URL above from your Intranet Zone (or really in any zone that is may have been mapped to)
Well for some silly reason, we first have to add this invalid URL to our Top Level Site collection before we can remove it again
So run this command to set the invalid URL into the -Zone
set-spsiteurl -identity https://myweb.stg.contoso.com -url http://myweb.contoso.com -zone intranet
if you perform
get-SPSiteURL -identity https://myweb.stg.contoso.com
you will now see that the Top Level Zones looks like this
Url Zone
https://myweb.stg.contoso.com Default
http://myweb.contoso.com/sites Intranet
Run
Get-SPSiteURL – identity https://myweb.stg.contoso.com/sites/teamA
And you will also see
Url Zone
https://myweb.stg.contoso.com/sites/teamA Default
http://myweb.contoso.com/sites/teamA Intranet
Now we can remove this invalid URL from the Top Level Intranet Zone.
remove-SPSiteURL -url http://myweb.contoso.com
then add the correct URL
set-spsiteurl -identity https://myweb.stg.contoso.com -url http://myweb.stg.contoso.com -zone intranet
And now this zone will cascade through the site collection underneath that hostname included the previously restored site collection.
Now perform
and you should see this:
Url Zone
https://myweb.stg.contoso.com/sites/teamA Default
http://myweb.stg.contoso.com/sites/teamA Intranet
 This entire process seemed confusing and probably more steps than were needed, but it seems to do the trick. As always if you have a better method, shoot me a line, lemme know!
Happy SharePointing!
#SPAdminLife

(387)

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.