rewrite outside root

Igor Sysoev is at
Wed Apr 2 22:05:51 MSD 2008

On Wed, Apr 02, 2008 at 09:53:23AM -0700, Rob Ruth wrote:

> My current Apache setup has a rewrite in place to search the DocumentRoot at
> '/var/www/' and if a file doesn't exist it looks in
> '/var/www/common'. All attempts to duplicate this is Nginx result in
> 'var/www/common' being appended to my root directory. Is it possible to
> rewrite outside the root in Nginx?

Instead of rewrite, use this:

    location / {
        root            /var/www/$host;
        log_not_found   off;
        error_page      404  =  @common;

    location @common {
        root            /var/www/common;

Igor Sysoev

More information about the nginx mailing list