June 18, 2009 04:13AM
2009/6/18 Igor Sysoev <is@rambler-co.ru>:
> On Wed, Jun 17, 2009 at 11:37:58PM +0100, Jools Wills wrote:
>
>> I got an error
>>
>> the "alias" directive must use captures inside location given by regular
>> expression in /etc/nginx/sites-enabled/default:70
>>
>> Quite a confusing message for me. The line in question.
>>
>> alias /home/$homedir/public_html/;
>>
>> which comes from
>>
>> # For requests starting with a tilde, break them into three components:
>> # 1. The username, everything after the tilde up to the first slash
>> # 2. The file location, everything after the username up to the last
>> slash
>> # 3. The trailing slash(es)
>> # Then, rewrite to go to the f~/ branch.
>> location /~ {
>>     if ($request_uri ~ ^/~([^/]*)(/.*[^/]|)(/*)$) {
>>         set $homedir $1;
>>         set $filedir $2;
>>         set $trailingslashes $3;
>>         rewrite ^/~([^/]*)(/|$)(.*)$ f~/$3;
>>     }
>> }
>>
>> # Here, the user-directory components have been parsed. Use an alias to
>> set
>> # the file directory prefix. But if the file at the requested URI is a
>> # directory, we jump to the ~/ branch for additional processing.
>> location f~/ {
>>     alias /home/$homedir/public_html/;
>>     if (-d /home/$homedir/public_html$filedir) {
>>         rewrite ^f~/(.*) ~/$1;
>>     }
>> }
>>
>> # Here, the request is for a directory in a user's home directory. We
>> check
>> # that the request URI contained trailing slashes. If it did not, then
>> we
>> # add the slashes and send a redirect. This circumvents Nginx's faulty
>> # internal slash-adding mechanism.
>> location ~/ {
>>     autoindex on;
>>     alias /home/$homedir/public_html/;
>>     if ($trailingslashes = "") {
>>         rewrite .* /~$homedir$filedir/ redirect;
>>     }
>> }
>>
>> (this code comes from this blog http://blog.sbf5.com/?p=6)
>>
>> Any ideas what this new error means. Seems related to a "new" feature
>> added in 0.7.40.
>
> You should use just:
>
>  locaiton ~ ^/~([^/]+)(/?.*)$) {
location ~ ^/~([^/]+)(/?.*)$

why use (/?.*) ?
wouldn't ^/~([^/]+)(.*)$ work as well?

>      alias /home/$1/public_html/$2;

is there behavior difference between
alias /home/$1/public_html/$2;
and
alias /home/$1/public_html$2;
?

>      autoindex on;
>  }
>

In the page I linked there's also block for php (which can't be
handled using alias).


--
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
Subject Author Posted

Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Jools Wills June 17, 2009 06:37PM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

edogawaconan June 17, 2009 10:33PM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Jools Wills June 18, 2009 02:43AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

edogawaconan June 18, 2009 03:09AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Jools Wills June 18, 2009 07:22AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Igor Sysoev June 18, 2009 03:41AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

edogawaconan June 18, 2009 04:13AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Igor Sysoev June 18, 2009 04:21AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

edogawaconan June 18, 2009 04:39AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Igor Sysoev June 18, 2009 04:46AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Jools Wills June 18, 2009 07:17AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Igor Sysoev June 18, 2009 07:34AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Jools Wills June 20, 2009 11:27AM

Re: Error with config when upgrading from 0.6.34 to 0.7.59 (the "alias" directive must use captures inside location given by regular expression)

Igor Sysoev June 20, 2009 11:38AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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