Rewrite outside root

My current Apache setup has a rewrite in place to search the
DocumentRoot at
‘/var/www/www.domain.com’ 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?

  • Rob

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/www.domain.com’ 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;
}