Re: Redirection with 301 for all subdomains with exception

From: Willy Tarreau <w#1wt.eu>
Date: Tue, 23 Jun 2009 07:02:21 +0200


On Mon, Jun 22, 2009 at 08:32:36PM +0200, Falco SCHMUTZ wrote:
> Hello everybody,
> Could you help to fix this configuration ?
>
> I need to redirect all sub domains except 5 (admin, pro, www, img*,
> domain.com without sub domain) to www.domain.com
>
> I test this setting, but did not work.
>
> acl good_subs url_beg admin pro www img*
> redirect location www.domain.com 301 if !good_subs

the host name is not in the url but in the "Host:" header. So you must do that instead :

   acl good_subs hdr_beg(host) -i admin. pro. www. img

> I have no idea for http://domain.com to http://www.domain.com and i did not
> know if img with wildcard work.

You can do that :

   acl good_subs hdr_beg(host) -i admin. pro. www. img domain.com

For the wildcard you don't need anything special as hdr_reg() matches at the beginning of the field. However if you need finer combinations, check with the regexes. It will be harder to configure but with infinite combinations.

Willy Received on 2009/06/23 07:02

This archive was generated by hypermail 2.2.0 : 2009/06/23 07:15 CEST