alias, regex and try_files am i doing it wrong, or is this a bug?

takigama nginx-forum at nginx.us
Fri Jan 13 04:36:41 UTC 2012


Ok, i was trying to do drupal as a subdirectory on my site, but i've hit
a problem and I think its a bug. Im using 10.04 ubuntu, the nginx ppa
with 1.0.11 nginx. 

If i have the following config's and i try to retrieve the file
http://mysite/drupal/somefile:

location ~ /drupal(.*) {
    index index.php;
    alias /local_config/$1;
    try_files $uri @drupalrewrite;
}

The file nginx is apparently trying retrieve
"/local_config//somefile/drupal/somefile" rather then
"/local_config//somefile", which leads me to believe $uri isnt being set
correctly by nginx.

If instead, i have this as a config:

location /drupal/ {
        index index.php;
        alias /local_config/;
        try_files $uri @drupalrewrite;
}

it does the right thing, and try files will attempt to get
"/local_config/somefile", so im really confused as to why it happens.
Either im doing something wrong or in the first example, $uri gets set
incorrectly? some small chunks of debug output to show what i mean:

>From the first config:
2012/01/13 04:03:18 [debug] 22504#0: *4 http request line: "GET
/drupal/somefile HTTP/1.1"
2012/01/13 04:03:18 [debug] 22504#0: *4 http uri: "/drupal/somefile"
2012/01/13 04:03:18 [debug] 22504#0: *4 http args: ""
...
2012/01/13 04:03:18 [debug] 22504#0: *4 using configuration
"/drupal(.*)"
...
2012/01/13 04:03:18 [debug] 22504#0: *4 trying to use file:
"/drupal/somefile" "/local_config//somefile/drupal/somefile" <-- path
looks incorrect?


>From the second config:
2012/01/13 04:26:58 [debug] 23019#0: *1 http request line: "GET
/drupal/somefile HTTP/1.1"
2012/01/13 04:26:58 [debug] 23019#0: *1 http uri: "/drupal/somefile"
...
2012/01/13 04:26:58 [debug] 23019#0: *1 using configuration "/drupal/"
...
2012/01/13 04:26:58 [debug] 23019#0: *1 trying to use file: "somefile"
"/local_config/somefile" <--- correct

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,221138,221138#msg-221138



More information about the nginx mailing list