Include don't Loading have Variables Path

Maxim Dounin mdounin at mdounin.ru
Wed Dec 30 13:08:43 MSK 2009


Hello!

On Wed, Dec 30, 2009 at 08:54:58AM +0100, Nginx fans wrote:

[...]

>  include    $web_root/.htaccess; This is load Rewrite Rule for nginx
> But Nginx don't load why?
> 
> [emerg]: CreateFile() "D:\nginx/conf/$web_root\.htaccess" failed (3: The
> system cannot find the path specified) in D:\nginx/conf/nginx.conf:42

Variables in nginx are evaluated at run time for each request.  On 
the other hand, configuration is loaded and parsed during startup.  
So you can't use variables for things needed during configuration 
parsing, e.g. "include".

Moreover, you don't need variables to set root.  It doesn't change 
between requests.  Using variables here is just waste of 
resources, warming the world for no reason.  You don't need 
variables, you need configuration macros which are expanded at 
time of reading configuration.

nginx doesn't support configuration macros, but they are 
trivially added by any config generation tools (e.g. make + sed 
will do the trick).

Maxim Dounin



More information about the nginx mailing list