string and variable concat in -f checks

Boris Bartsyts bartzitz at gmail.com
Wed Apr 11 14:42:31 MSD 2007


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.


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;
>         }
>     }
> 
> 






More information about the nginx mailing list