Hi All,
I have a significant number of sites I'm migrating off a Windows server to Ubuntu using WordOps to front end the process. Most of these sites respond on multiple domains (very often all of .com.au. .com & .au variation of the name).
In Windows this is simple to handle, just add bindings for all the domain names, add the standard 'Canonical Domain Name' rule to the IIS rewriter, job done.
I have trawled the documentation and this forum for how to do the same in WordOps / nginx. The apparent best answer is this: https://community.wordops.net/d/240-how-to-add-multiple-domains-to-one-site-in-wordops but that seems to be absurdly hard. Do you really have to create multiple sites, one for each domain? That would mean pretty much tripling the work at least for each site; in the worst case scenario I would literally have to create seventeen sites to port across one of the sites.
Surely doing something like this in the sites-available/domain.tld file would be far easier:
# WordOps created server block for the canonical domain name
server {
server_name canonicaldomain.com.au www.canonicaldomain.com.au
;
. # all the other usual WO inclusions
.
}
# Add the alternate domain names in a server block with rewrite to canonical domain
server {
server_name domain.com www.domain.com
domain.com.au www.domain.au
;
rewrite ^/(.*)$ https://canonicaldomain.com.au/$1 permanent;
}
Am I missing something obvious? Is there any reason that won't work? If so it's a hell of a lot less work that the suggested approach.