string and variable concat in -f checks

Igor Sysoev is at
Wed Apr 11 00:00:12 MSD 2007

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;

Igor Sysoev

More information about the nginx mailing list