Welcome! Log In Create A New Profile

Advanced

Re: Variable $1 is Empty

lhmwzy
October 14, 2010 08:04AM
I think you should change


server {
listen 80;
server_name ~^(.+)\.mydomain\.com$;
location / {
root /home/$1/public_html;
index index.html index.htm;
}
}

to


server {
listen 80;
server_name ~^(.+)\.mydomain\.com$;
set $name $1;
location / {
root /home/$name/public_html;
index index.html index.htm;
}
}

2010/10/14 Indra Setiawan <suryo.dinoto@gmail.com>:
> Hi everyone,
>
> This is my first time installing nginx. I install it on my Debian
> 5.0.3 VPS and use Debian's repository to install it (version: 0.6.32).
>
> I'm having problem with using regular expression at server_name.
> Here's my configuration:
>
> server {
>  listen    80;
>  server_name    ~^(.+)\.mydomain\.com$;
>  location / {
>    root    /home/$1/public_html;
>    index    index.html  index.htm;
>  }
> }
>
> When I hit myusername.mydomain.com, where
> /home/myusername/public_html/ is exist. It gives me a 404 error. And
> when I view the log file, seems like $1 is null or something.
>
> 2010/10/14 10:47:08 [error] 4924#0: *3 "/home//public_html/index.html"
> is not found (2: No such file or directory), client: 173.245.73.113,
> server: ~^(.+)\.mydomain\.com$, request: "GET / HTTP/1.1", host:
> "myusername.mydomain.com"
>
> Am I doing wrong?
> Any helps will be appreciated, thanks in advance.
>
> Indra
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

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

Variable $1 is Empty

Indra Setiawan October 14, 2010 07:08AM

Re: Variable $1 is Empty

lhmwzy October 14, 2010 08:04AM

Re: Variable $1 is Empty

António P. P. Almeida October 14, 2010 08:46AM

Re: Variable $1 is Empty

Maxim Dounin October 14, 2010 08:54AM

Re: Variable $1 is Empty

Maxim Dounin October 14, 2010 09:00AM

Re: Variable $1 is Empty

Indra Setiawan October 14, 2010 12:22PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 237
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