Setup Storefront Hostname In Salesforce Commerce Cloud

Give a catchy, memorable, and purposeful site name to your salesforce commerce cloud site

Savan Koradia
Salesforce Commerce Cloud Tales

--

Image created by the author

Once the site is ready to launch for everyone, it should be easier for everyone to reach and access it. The essential factor here is the domain name of your store. If the store’s domain name is easier and more catchy to remember, people would love to come back more often.

Below are the topics covered in this article

  • What is Hostname Alias?
  • Why it is important?
  • Point the domain name to your SFCC server
    - Using CNAME
    - Using IP Address
  • Configuring Hostname alias in SFCC
    - Basic settings
    - Always redirect to WWW
    - Instance specific
  • Demandware.net Origin Shielding
  • Alias JSON Validation
  • Setup Custom Domain on Your Sandbox
  • Useful Links

The Salesforce Commerce Cloud platform provides access to some modules related to hostname settings, redirection, and CDN configurations. These configurations are essential to achieve the end result of having a proper domain hostname and redirection throughout the content.

As we have discussed in the previous article, SFCC provides a list of instances in the package that is accessible in default domains. Here take an example of the SiteGenesis:

The production domain will require to be changed with the real hostname domain as it is the instance everyone will be accessing. This also helps for better SEO purposes on the production instance.

DNS Settings

When you are familiar with settings to set on the domain name providers like godaddy.com from where you have purchased the domain name for your store, you will notice that the purchased domain name requires redirection to the destination server where the site is hosted.

This can be done in two ways:

  • Using the IP address of the server
  • Using the CNAME (Canonical Name) of the server

Get the CNAME

eCDN settings in Administrator section SFCC BM (image by author)

To continue with eCDN and generate CNAME, you need to set up basic settings in your site alias:

{
"__version": "1",
"settings": {
"http-host": "www.yourstore.com",
"https-host": "www.yourstore.com"
}
}

Select the hostname in eCDN and start creating a zone.

After completing the step you would be able to see a list of all the created zone for each domain.

Generate CNAME (image by author)

GET the IP address

To Get the IP address you require to run a command in the terminal of your computer using the default production domain name.

Find the IP address of the server (image by the author)
nslookup production-domain-name

You would find the result in the address section. Here: 160.8.37.240

Hostname alias settings are specific to each instance. These settings can not be replicated using a data replication process.

Your merchandising team or Solution Architect will require to do changes manually for each instance separately.

Let’s consider you have added CNAME or IP address in your domain name provider. Now, it is time to set up an alias as per your store’s requirements.

Navigate through: Business Manager > Select the Site > Merchant Tools > SEO > Aliases

Alias path in the merchant tool (image by the author)
Setup alias in JSON format (image by the author)

Basic Settings:

If your domain name is www.yourstore.com, alias JSON should be created with this information:

{
"__version": "1",
"settings": {
"http-host": "www.yourstore.com",
"https-host": "www.yourstore.com"
}
}

__version must remain as 1.

“http-host” and “https-host” should contain the domain name of your site. Ideally, the checkout steps site must be on the HTTPS protocol for security. It is better that your while is running on the HTTP protocol only.

Always redirect to the WWW domain:

If your expectation is to redirect https://yourstore.com to https://www.yourstore.com apply some necessary changes in alias settings:

{
"__version": "1",
"settings": {
"http-host": "www.yourstore.com",
"https-host": "www.yourstore.com"
},
"www.yourstore.com": [],
"yourstore.com": [
{
"host": "www.yourstore.com",
"path": "/"
}
]
}

Instance Specific:

Since Alias settings can not be replicated using data replication, you can set an alias for each instance as you see fit.

If you have created such a subdomain via your domain name provider for staging instance, you can set up it for staging as follows:

{
"__version": "1",
"settings": {
"http-host": "www.staging-yourstore.com",
"https-host": "www.staging-yourstore.com"
},
"www.staging-yourstore.com": [],
"staging-yourstore.com": [
{
"host": "www.staging-yourstore.com",
"path": "/"
}
]
}

Demandware.net Origin Shielding

Since the 2022 releases, origin shielding is implemented for development and production instances. This means you can only access Development and production instance sites using domain names other than generic like

Be it OCAPI service or storefront access, using the above generic domain will show an error instead of taking it to the right place. It helps to protect data and against DDoS service attacks.

Alias Validation

The Salesforce Commerce Cloud platform will save the configuration as it is you have provided. It will not validate rules and format. So it is better to validate provided JSON format prior to saving it. Use one of your favorite JSON formatter: https://jsonformatter.curiousconcept.com/ or https://jsonformatter.org/

When you have changed the existing alias hostname JSON, use Diff the JSON tool to check the changes done in new configurations.

Compare any JSON content and validate the changes (image by author)

Setup Custom Domain on Your Sandbox

Once the above steps are clear it is easier to set up a custom domain alias on your own sandbox. For this, you do not require to purchase any domain from Domain Name providers.

Follow the below steps:

  1. Decide the custom domain name: www.my-store.local
  2. Configure alias
{
"__version": "1",
"settings": {
"http-host": "www.my-store.local",
"https-host": "www.yourstore.com"
}
}

3. Find the IP address of your server: 1.2.3.4

4. Open the /etc/hosts File on your computer and add an entry:

# IP            Domain
1.2.3.4 www.my-store.local

After saving, accessing www.-my-store.local will take you to your sandbox.

--

--

Savan Koradia
Salesforce Commerce Cloud Tales

SFCC Solution Architect, Mentor. I write about technical learning, improvements, work culture, mentoring.