string and variable concat in -f checks

Igor Sysoev is at rambler-co.ru
Fri Apr 13 00:29:18 MSD 2007


On Wed, Apr 11, 2007 at 01:42:31PM +0300, Boris Bartsyts wrote:

> thanks Igor, i've ended up with this:
> 
>         rewrite ^(.*)/$  $1/index.html;
> 
>         if (-f $document_root/cache$uri) {
>             root   /var/www/myspace/cache;
>             break;
>         }
> 
>         rewrite ^(.*)/index.html$  $1/index.php;
> 
> 	... further rewrite rules here ...
> 
> 
> i couldn't get rid of additional rewrites for index.html
> "index index.html index.php" doesn't help because i have index.php only
> in /root and index.html only in /root/cache folder.

I think it's better to use such configuration:

     location / {
         root /var/www/myspace/cache;
         index index.html;
         error_page  404  = /miss;
     }

     location = /miss {
         proxy_pass   http://backend;

         # do not write any URI part after "http://backend" !!!
         # then proxy_pass gets original client URI, but not "/miss"
     }


> 
> On Wed, 2007-04-11 at 00:00 +0400, Igor Sysoev wrote:
> > On Tue, Apr 10, 2007 at 06:08:18PM +0300, Boris Bartsyts wrote:
> > 
> > > is it possible to do something like this:
> > > 
> > > if (-f /cache$request_filename) {
> > >     rewrite ^(.*)$    /cache$1;
> > > }
> > > 
> > > it should check for the requested file in the /cache dir and if it
> > > doesn't exist proceed to remaining rewrite rules. i can't make this
> > > clause working, please correct it or point to other soultions.
> > 
> > $request_file is "$document_root$uri".
> > If this is what you suggest, then you should use
> > 
> >     location / {
> > 
> >         root   /data/w3;
> > 
> >         if (-f /cache$request_filename) {
> > 
> >             root    /cache/data/w3;
> >             break;
> >         }
> >     }
> > 
> > 
> 
> 

-- 
Игорь Сысоев
http://sysoev.ru





More information about the nginx mailing list