Welcome! Log In Create A New Profile

Advanced

Re: Vhost support

António P. P. Almeida
January 29, 2011 03:46AM
On 29 Jan 2011 07h58 WET, appa@perusio.net wrote:

> On 29 Jan 2011 07h35 WET, markc@renta.net wrote:
>
>> On 29/01/11, Igor Sysoev wrote:
>>>> This is pretty good but I want to reverse the domain.org $host
>>>> variable and provide, say, a $rhost variable of "org/domain".
>>> [...]
>>>
>>> http://nginx.org/en/docs/http/server_names.html#regex_names
>>
>> Thanks for the reply, but how do I take into account...
>>
>> domain.com
>> www.domain.com
>> www.username.domain.com
>>
>> so, ie; the first one becomes com/domain and the last one becomes
>> com/domain/username/www ?
>>
>> I have tried this but couldn't get it to work...
>>
>> server {
>> server_name ~^(?<p1>\.)?(?<p2>\.)?(?<p3>\.)?(?<p4>\.)?(?<p5>\.);
>> #server_name
>> #~^(?P<p1>\.)?(?P<p2>\.)?(?P<p3>\.)?(?P<p4>\.)?(?P<p5>\.);
>> location / {
>> root /var/www/$p5/$p4/$p3/$p2/$p1;
>> }
>> }
>
> Try with:
>
> server_name
> ~^(?<p1>[^.]*)[\.]*(?<p2>[^.]*)[\.]*(?<p3>[^.]*)[\.]*(?<p4>[^.]+)\.(?<p5>[^.]+);

Make it:

server_name ~^(?<p1>[^\.]*)[\.]*(?<p2>[^\.]*)[\.]*(?<p3>[^\.]*)[\.]*(?<p4>[^\.]+)\.(?<p5>[^\.]+)$;

Forgot to escape the "." in the named capturing groups.

--- appa


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Vhost support

Mark Constable January 29, 2011 02:08AM

Re: Vhost support

Igor Sysoev January 29, 2011 02:10AM

Re: Vhost support

Mark Constable January 29, 2011 02:38AM

Re: Vhost support

Igor Sysoev January 29, 2011 03:04AM

Re: Vhost support

António P. P. Almeida January 29, 2011 03:06AM

Re: Vhost support

António P. P. Almeida January 29, 2011 03:46AM

Re: Vhost support

Mark Constable January 29, 2011 07:40AM

Re: Vhost support

Igor Sysoev January 29, 2011 01:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 139
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready