location = / strange behavior

Igor Sysoev is at rambler-co.ru
Tue Aug 4 19:31:17 MSD 2009


On Tue, Aug 04, 2009 at 10:28:22AM -0400, fritz wrote:

> Hi.
> 
> If URI is "/" I need to show index.html.
> Else I need to execute a php script.
> 
> According to http://sysoev.ru/nginx/docs/http/ngx_http_core_module.html#location
> my config looks like this:
> 
> server {
>         listen  80;
>         server_name             localhost;
>         location = / {
>               root   /home/www;
>                index  index.html;
>         }
>        location  / {
>                 fastcgi_pass   127.0.0.1:8888;
> 
>                 fastcgi_param  SCRIPT_FILENAME  /home/www/click.php;
>                 ...
>         }
> }
> 
> But always triggers only the second rule.
> Tried with 0.6.32 and 0.7.59.

You need also to add

         location = /index.html {
               root   /home/www;
         }

since nginx does internal redirect "/" -> "/index.html".


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list