How to match domains starting with "admin"

Paul A. Procacci pprocacci at datapipe.com
Mon Jul 9 21:49:27 CEST 2012


On Mon, Jul 09, 2012 at 02:47:36PM -0500, Paul A. Procacci wrote:
> On Mon, Jul 09, 2012 at 09:57:38AM -0700, Abraham Cruz Sustaita wrote:
> >    I have several sites on my servers, so I need to configure one admin
> >    subdomain for each one. However, I don't want to make:
> >
> >    if (req.http.Host ~
> >    "(?i)([1]admin.domain1.com|[2]admin.domain2.com|[3]admin.domainN.com)?$
> >    ") {}
> >
> >    Can I do this only with one regular expression of the type
> >    (admin\.(.*)) ?
> >
>
> Something like the following will match anything prefix'd with `admin`.
> You'd have to include the suffixes manually.  Luckily, there aren't too many
> tld's for this to be a major concern.
>
> ^admin\.[^\.]+\.(?=(com|net|org))$
>
> You can capture the entire hostname by including grouping operators
> around the entire regex:
>
> ^(admin\.[^\.]+\.(com|net|org))$
>
> ~Paul

Sorry for the email to self here.  The second regex was a bad copy/paste and
should have been:

^(admin\.[^\.]+\.(?=(com|net|org)))$

~Paul

________________________________

This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.



More information about the varnish-misc mailing list