I have a primary domain name ‘www.mydomain.org.uk’, and I want to redirect my additional domain name ‘www.mydomain.com’ to that, whilst preserving the server relative path.
Can anyone explain how to do this? Is it perhaps achieved by a multiple value for site_hosts in wordpress_sites.yml? It’s not immediately obvious from the documentation.
Let’s say I’ve already got all my desired domain names pointing at the IP address of my server. This might include records for both www and no-www domains.
Normally, the next thing I would do would be to add a redirect to my .htaccess, pointing all additional domains to the primary domain. This would look like this:
Update: I’m looking into a way of setting up the redirects within the nginx conf file, instead of a htaccess.
This is going to involve editing trellis/roles/wordpress-setup/templates/wordpress-site.conf.j2. The logic will be that if there is more than one value in site_hosts, then additional hosts will be redirected to the first host.
@cfx - I appreciate that initially this may not have looked like a Trellis related question, but would you now consider listing it in the forum again? I would appreciate any help, and I think the answer could be useful to other users.
Trellis doesn’t automatically set up redirects for site_hosts. It just automatically sets up the Nginx site to serve those hosts as well (but without redirects).
I suggest creating a simple Nginx conf for the redirects and using Nginx Includes.