Roots Discourse

Best way to allow site to respond to 2 domains (with trellis)

I have a site on trellis that needs to respond to both domain1.com and domain2.com (not redirect). What would be the best way to set this up? Placing 2 canonical domains in wordpress_sites.yml results in the latter redirecting to the first.

Let’s not get into the duplicate content/SEO discussion, as it just isn’t particularly relevant in this specific situation, though I understand the concerns.

The following is my wordpress_sites.yml file for reference:

wordpress_sites:
location1.com:
site_hosts:
- canonical: location1.com
redirects:
- www.location1.com
- canonical: location2.com
local_path: …/sites/location1.com
repo: ‘git@bitbucket.org:location1.com.git’
branch: production
multisite:
enabled: false
ssl:
enabled: false
provider: letsencrypt
hsts_include_subdomains: false
cache:
enabled: false

Any input at all would be appreciated.

No it doesn’t?
Only domains under redirects will do that, canonicals will keep their url

Well, I guess that’s what’s throwing me off. I thought this as well, but I’ve deployed to 2 servers and both are redirecting the latter to the first as soon as I add it.

Are you sure your syntax is like this:

example.com:
  site_hosts:
    - canonical: example.com
      redirects:
        - www.example.com
    - canonical: example.co.uk
      redirects:
        - www.example.co.uk

Yep - that’s exactly the syntax. I did however find that an nginx include was mistakenly being used so I’m going to work on resolving that and I’ll report back.

That’s probably it yes!
You can always check your /etc/nginx/sites-available/domain1.com.conf file on your droplet to check for any extra server blocks for your domain2 server name.

Sorry for not responding initially, but yes this accidental include was the culprit. Thanks for chiming in.

1 Like