Redirect URI: how to define exakt match, no pattern


#1

Hello!
I have setup a mailserver that serves 3 webservices:
mail.mydomain.de
webmail.mydomain.de
sogo.mydomain.de

In order to ensure that requests are ending up at the same host, I have defined this rule:
acl mail hdr(host) -i mail.mydomain.de hdr(host) -i webmail.mydomain.de hdr(host) -i sogo.mydomain.de
use_backend mail_server if mail

This works as expected.

In addition I want to redirect the following URLs:
hxtp://mydomain.de/mail -> mail.mydomain.de
hxtp://mydomain.de/webmail -> webmail.mydomain.de
hxtp://mydomain.de/sogo -> sogo.mydomain.de

I started with a ACL like this:
acl redir_webmail path_beg /webmail
http-request redirect location https://webmail.%[hdr(host)] code 301 if redir_webmail

The issue here is that when I enter
hxtp://mail.mydomain.de/webmail
this will be redirected to
hxtp://webmail.mail.mydomain.de
and this is incorrect.

Can you please advise?

THX


#2

I started with a ACL like this:
acl redir_webmail path_beg /webmail
http-request redirect location https://webmail.%[hdr(host)] code 301 if
redir_webmail

The issue here is that when I enter
hxtp://mail.mydomain.de/webmail
this will be redirected to
hxtp://webmail.mail.mydomain.de
and this is incorrect.

Can you please advise?

Hi,

You want to turn location into prefix into your redirect rule.

Baptiste


#3

OK, I think I can simplify it.
The redirection rule should follow this if… then condition:
if mydomain.de/webmail (or www.mydomain.de/webmail)
then redirect to webmail.mydomain.de
etc.
if mail.mydomain.de/webmail
then 503