Mailinabox: How to configure domain redirects
Mailinabox usually wants control over the base domain (so that it can handle emails to that doain).
For me this meant the domain zechendorf.com
was controlled by mailinabox.
Since the website runs at www.zechendorf.com
I needed a clean way to redirect.
Fortunately mailinabox supports overwriting the nginx configuration for domains. This can be achieved by
adding a file [domainname.tld].conf
in the /home/user-data/www/
folder. For me this meant creating
/home/user-data/www/zechendorf.com.conf
with the following content:
location / {
return 301 https://www.zechendorf.com$request_uri;
}
To apply the changes, you will need to run the ./web_update
script at ~/mailinabox/tools
and also restart
nginx with service nginx restart
.
Now all URL calls from zechendorf.com
are being redirected to www.zechendorf.com
.