Sub-domain in variable
Nikolas Stevenson-Molnar
nik.molnar at consbio.org
Tue Mar 26 18:19:05 UTC 2013
The "www" part is probably causing a problem too. As the regex is
written it will only match "www.<subdomain>.<domain>.<tdl>" which I'm
guessing isn't what you intent. I would instead treat "www" as another
possible subdomain.
~^(?<subdomain>[^\.]*\.)?(?<domain>[^\.]*)\.(?<tld>[^\.*)$
Note I haven't tested this, but it's similar to a pattern I've used. The
$subdomain variable will be either the subdomain, "www", or will be
empty. It would need some more tweaking to handle multiple subdomains
(one.two.domain.com).
_Nik
On 3/26/2013 11:01 AM, huttarichard wrote:
> Thanks lot, but still wont to work.
> And how i set $subdomain to "default" if subdomain doesnt exists?
>
> I try this:
> ~^(www\.)(?<subdomain>[^\.]*)(?<domain>[^\.]*)\.(?<tld>[^\.]*)$
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,237799,237814#msg-237814
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
More information about the nginx
mailing list