URI pattern baffling problem

António P. P. Almeida appa at perusio.net
Tue Feb 8 16:24:38 MSK 2011

On 8 Fev 2011 13h11 WET, igor at sysoev.ru wrote:

> On Tue, Feb 08, 2011 at 11:55:27AM +0100, Gregory Agerba wrote:
>> Thanks Antonio, now that worked.
> You should think not in negative way:
> if ($request_uri !~* "^/documents/(?:[A... ") { { rewrite ^
> http://www.google.com/ permanent; }
> but in positive way:
> location ~* "^/documents/(?:[A... " {
> ...
> }
> location / { rewrite ^ http://www.google.com/ permanent; }

I agree. But the problem stems from the fact that most applications
don't ever consider the configuration at the server or virtual host
level. Apache has the directory context (.htaccess) so people tend to
make their applications depend on it as much as possible and on the
server or vhost config as little as possible.

Since you cannot define locations in a directory context (.htaccess)
the only solution is to think backwards and hack something revolving
around mod_rewrite.

It's a deeply rooted habit. It's not easy to make the transition to
Nginx where there's no directory context, hence things must be thought
out differently from the outset. But yes we should insist on changing
that habit. Thinking backwards makes Nginx config feel strange and

--- appa

More information about the nginx mailing list