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?

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

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.