I am developing a site for a client and the setup is a little bit more complex than what I am used to. They bought various domain extensions to which .com is the canonical one.
wordpress_sites:
example.com:
site_hosts:
- canonical: example.com
redirects:
- example.fr
- www.example.fr
- example.eu
- www.example.eu
- example.pt
- www.example.pt
local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
repo: git@github.com:example/example.com.git # replace with your Git repo URL
repo_subtree_path: site # relative path to your Bedrock/WP directory in your repo
branch: master
multisite:
enabled: false
ssl:
enabled: false
provider: letsencrypt
cache:
enabled: false
Do I really need to write these 6 redirects to handle all the cases?
Is it possible to use a regex such as (www.)?example.(fr|eu|pt)
Or something similar?
I am not really sure I am doing it right, I would appreciate a quick feedbacks to point me in the right direction.
If all you want is a regex for redirect, it looks like you might be able to do that. It looks like Trellis is just iterating over the items in redirects, so in theory I think you could put a single item in there that contains a properly-formatted regex that nginx understands. That’s just based on 5 minutes of Googling though, not actual experience, so ¯\(ツ)/¯
Alright I still have no idea how CNAME works under the hood but remove all the redirects lines with the “www” and replaced all the others by a regex. It works.