Set the Primary Domain
Learn how to set the primary domain for your site.
Pantheon uses the term primary domain to refer to a single domain used to serve all traffic from a site. For example, configuring www.example.com
as the primary domain means that requests to example.com
(or any other custom domain connected to the environment) all get redirected to www.example.com
. This assumes that you have added both example.com
and www.example.com
to the Site Dashboard.
Redirecting all traffic to a primary domain is a best practice for SEO since it avoids duplicate content. It also prevents session strangeness, where a user can be logged in to one domain but logged out of other domains at the same time, and it can make it easier to measure and monitor website traffic.
Set a Primary Domain via the Dashboard
With a Primary Domain set at the platform level, all other domains (except the platform domain) will be pointed to your Primary domain at the root level. If you want to redirect secondary domains to specific pages on your site (for example, olddomain.com
to newdomain.com/old-landing-page
), do not set a Primary Domain. Instead use PHP redirects.
Navigate to the environment you want to set a primary domain for (typically Test or Live), and then select Domains / HTTPS.
Ensure that all domains have been added and are listed.
Navigate to the Choose Primary Domain section, select the domain to which traffic should be redirected, and then click Save Configuration.
You will only see the primary redirect option when you have two or more custom domains attached to your environment. If you want to redirect a single platform domain, you must do the primary redirect via PHP. For example, live-mysite.pantheonsite.io
to www.example.com
Set a Primary Domain with Terminus
Install or upgrade to the latest version of Terminus.
Use Terminus to add the primary domain. In this example, replace:
my-site
with your site namelive
if you'd like to set it for a different environmentwww.example.com
with your primary domain
terminus domain:primary:add my-site.live www.example.com
Update or Remove Primary Domain
Update the Primary Domain using either method provided in the previous section.
Remove an existing selection for the Primary Domain on any environment using Terminus:
terminus domain:primary:remove my-site.live
Replace my-site
with your site name, and live
with the environment you're removing a primary domain from.
Verify
You can confirm that the Primary Domain has been removed with cURL pointed at one of your other custom domains, which would previously have been redirected:
curl -I https://example.com
HTTP/2 301
retry-after: 0
server: Pantheon
location: https://www.example.com/
x-pantheon-redirect: primary-domain-policy-docdate: Wed, 05 Feb 2020 16:43:21 GMT
x-served-by: cache-mdw17355-MDW
x-cache: HIT
x-cache-hits: 0
x-timer: S1580921002.586800,VS0,VE1
age: 0
accept-ranges: bytes
via: 1.1 varnish
content-length: 0
The presence of x-pantheon-redirect: primary-domain-policy-doc
indicates that the domain is still being pointed at the former Primary Domain. Contact support if this value persists.