Setting Up Multiple Hosts For A Sitecore SXA Site

October 16, 2021

By David Austin

By default, when you setup a Sitecore SXA site by first creating a Tenant and then the Site itself, your site will be operating under the settings where it accepts calls from any host bound to that particular site.

For the majority of clients, this will be perfectly fine, but what if you have a client that would like a separate URL, say a preview site, which points to the master database, instead of the web database.

Now in a typical Sitecore site, setting up a separate site definition in a patch file would be all you need to do. It's quick, it's easy. That doesn't work for an SXA site.

Site Grouping

Let's navigate down to the Site Grouping folder located within our Settings folder: /sitecore/content/<Tenant>/<Site>/Settings/Site Grouping

Open it up and you'll see a site node with the same name as your site.

On this item, you'll find everything that you'd typically find in the standard site definition. But how do we make one for say a preview site with a url https://preview.companyname.com.

First step, let's duplicate that item.

Once duplicated, let's go in and update the hostname and target hostname with the new URL. For our requirement, we'll also change the database to master.

Update the hostname and target hostname with the new URL in the new Site Grouping in Sitecore

We can then go back to the original site definition item and update the hostname there, or leave it as is (I'll show you why shortly).

SXA Site Manager

With those in place, let's open up the SXA Site Manager.

Opening the SXA Site Manager in Sitecore

Once it loads, you'll see that our preview site is in the list, but it's currently showing as being in conflict. That's because it's below the site that accepts all hosts.

Sitecore showing there is a conflict with the new preview site created

Let's resolve that by selecting the Demo Preview site in the list, and in the top bar click the Move Up button. Once that's done, you'll now see the site is green.

Resolving the conflict by selecting the Demo Preview site in the list in Sitecore

We're able to leave the host as a * for the original site as a catch all, hence the reason we don't need to update it with the original hostname. You may, depending on your environment, need to do this. It all depends on your needs.

Be sure, once your change is done, click the Publish button in the top bar to finalize the change.

Image of Fishtank employee David Austin

David Austin

Development Team Lead | Sitecore Technology MVP x 3

David is a decorated Development Team Lead with Sitecore Technology MVP and Coveo MVP awards, as well as Sitecore CDP & Personalize Certified. He's worked in IT for 25 years; everything ranging from Developer to Business Analyst to Group Lead helping manage everything from Intranet and Internet sites to facility management and application support. David is a dedicated family man who loves to spend time with his girls. He's also an avid photographer and loves to explore new places.