Resolving a custom hostname during a request
When you create a custom hostname it's associated with either defaultContextId or defaultSiteId, or both. These IDs help determine access to specific applications supported by Sitecore. After your custom hostname is verified, it can be used to route traffic to the correct service based on its associated IDs.
Sitecore identifies the target service or application of your request, based on the hostname you use and whether you include the tenant name in the request URL. Here are the possible scenarios:
A custom hostname can retrieve media from any tenant inside the organization if you include the tenant name in the request URL. For example https://customhostname.io/v1/media/edge/images/<tenantName>/media/banner-image.jpg.
If you don't specify the tenant name in the URL, then the associated Context ID is used to resolve the tenant. For example https://customhostname.io/v1/media/edge/images/banner-image.jpg.
-
Use a custom hostname without
ContextIdorSiteIdIf you use a custom hostname in your request without explicitly including a
ContextIdin the query parameter or header, or aSiteIdin the query parameter or body, the system automatically uses thedefaultContextIdordefaultSiteIdlinked to that custom hostname. This simplifies your requests because you don't have to manually include those IDs every time. -
Use a custom hostname with
ContextIdorSiteIdIf you use a custom hostname along with a
ContextIdin the query parameter or header, or aSiteIdin the query parameter or body, the system will prioritize these provided IDs over the default ones associated with the hostname. -
Use the default hostname
If you use the default
edge-platform.sitecorecloud.iohostname, there are no specific IDs automatically associated with it. To make sure your request reaches the correct destination, you need to include either theContextIdorSiteIdin the request.
Custom hostname media item requests
Custom hostnames can only be used with the live context ID and for media items published to Experience Edge.
To prevent search engines from indexing your media on the http://edge.sitecorecloud.io domain, Experience Edge media requests include the X-Robots-Tag:noindex header.
However, when requesting a media item from a custom hostname, you can use the relative path /v1/media/edge/images/ to have the X-Robots-Tag:noindex header omitted from the response. This lets search engines properly index media items on your custom domain, improving SEO.
To make a media request using a custom hostname, reconstruct the URL to combine the custom hostname, relative path /v1/media/edge/images/, and relative path to the media item.
For example, if the Experience Edge media item URL is:
http://edge.sitecorecloud.io/yourcompany1-yourcompanyltd-p49d-fb1a/media/path/to/mediaFolder/HeroBanner.pngand your registered custom hostname is:
media.your-company.comThen you can request the media item from the custom hostname URL:
https://media.your-company.com/v1/media/edge/images/yourcompany1-yourcompanyltd-p49d-fb1a/media/path/to/mediaFolder/HeroBanner.png