Best way to redirect root page to /mail?

Hi,

I would be interested in re-directing the default page:

"this is a mail-in-a-box

take control of your email at https://mailinabox.email/"

to go straight to /mail. So when a user accesses http://mail.domain.com it will be redirected to https://mail.domain.com/mail (the http to https already works out of the box).

Is this possible?

1 Like

yup u can change it on nginx config /etc/nginx/conf.d/local.conf

put this in TLS and SSL (80 and 443)

#return 301 https://yourdoma.in$request_uri; //make sure your comment your return 301
location = / {
	return 301 https://$server_name/mail;
}
1 Like

Thanks aa6my, that worked!

Kinda late to the party but I was wondering if that wonā€™t be overwritten. The file warns for this at the top. Now Iā€™m thinking Iā€™d rather solve this in a separate .conf but Iā€™m struggling with that.

Try this alternative: Access Mailbox From A Subdomain - #3 by just4t

Hi Gabriel, thank you for your reply.

I indeed saw that post after my response here but didnā€™t really like it that much. I thought doing a refresh this way leaves room for the client to do with the refresh as it pleases? Maybe Iā€™m mistaken.

Normally Iā€™d try doing it with a header(ā€˜location: ā€¦ā€™); in an index.php but for that Iā€™d also have to alter /etc/nginx/conf.d/local.conf since that isnā€™t in the index directive there. But that brings us back to square one I guess :smile:

Anyway, Iā€™ll give that solution a go. Really like MIAB so this is a minor ā€œinconvenienceā€ at most.

Again thank you very much!

I did this with a simple meta redirect in HTML, on an otherwise empty index page at / (which for me is the /home/user-data/www/default/ since I donā€™t host sites on my MIAB)

Jeah, neither are we so weā€™ll go for that as well.

Great to see this community being so alive.

Thank you very much!

What I did: /etc/nginx/conf.d/local.conf is an autogenerated file. So if you add a 301 you probably will lose that change.
I looked for the file that generates it (the important part) find / -name "nginx-primaryonly.conf" and I added these lines to the beginning
location = / {
return 301 https://$server_name/mail;
}

MiaB will overwrite possibly every nginx configuration file on update.

Not sure why the HTML header redirect on refresh is an issue.

Sure, but will use that file to regenerate new ones.