--> -->

By default, a Platform.sh app is available at a domain generated by Platform.sh. The following resources will help you take your application live on your custom domain.

Summary of steps 

In this short section we will give you a simple, typical example. See the Step by step guide for more complex cases.

Set your domain 

Now, add a single domain to your Platform.sh project for mysite.com.

Using the CLI type:

platform domain:add mysite.com

You can also use the management console for that.

As soon as you do, Platform.sh will no longer serve master-def456-abc123.eu-2.platformsh.site at all. Instead, {default} in routes.yaml will be replaced with mysite.com anywhere it appears when generating routes to respond to.

You can still access the original internal domain by running platform environment:info edge_hostname -e master.

Configure your DNS provider 

On your DNS provider, you would create two CNAMEs:

mysite.com should be an ALIAS/CNAME/ANAME to master-def456-abc123.eu-2.platformsh.site. www.mysite.com should be a CNAME to master-def456-abc123.eu-2.platformsh.site.

Result 

Here’s what will now happen under the hood. Assume for a moment that all caches everywhere are empty. An incoming request for mysite.com will result in the following:

  1. Your browser asks the DNS network for mysite.com's DNS A record (the IP address of this host). It responds with “it’s an alias for www.master-def456-abc123.eu-2.platformsh.site” (the CNAME) which itself resolves to the A record with IP address 1.2.3.4 (Or whatever the actual address is). By default DNS requests by browsers are recursive, so there is no performance penalty for using CNAMEs.
  2. Your browser sends a request to 1.2.3.4 for domain mysite.com.
  3. Your router responds with an HTTP 301 redirect to www.mysite.com (because that’s what routes.yaml specified).
  4. Your browser looks up www.mysite.com and, as above, gets an alias for www.master-def456-abc123.eu-2.platformsh.site, which is IP 1.2.3.4.
  5. Your browser sends a request to 1.2.3.4 for domain www.mysite.com. Your router passes the request through to your application which in turn responds with whatever it’s supposed to do.

On subsequent requests, your browser will know to simply connect to 1.2.3.4 for domain www.mysite.com and skip the rest. The entire process takes only a few milliseconds.