No input file specified by FastCGI

Igor Sysoev is at rambler-co.ru
Tue Jun 16 18:00:06 MSD 2009


On Tue, Jun 16, 2009 at 09:39:55AM -0400, meal wrote:

> Hi,
> We have our own framework written in PHP, but it's using .html extension (and change of this is not possible).
> So when I put appropriate block in config, part of site is working, but few rewrites is not.
> 
> here is my .html parsing block
> 
> location ~ \.html$ {
>         if (!-f $request-filename) { return 404; break; }
>   root /path/to/files;
>   fastcgi_pass 127.0.0.1:8000;
>   fastcgi_index index.html;
>   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>   fastcgi_intercept_errors on;
>   include fastcgi_params;
>  }
> 
> 
> and rewrite rule that isn't working there:
> 
>   rewrite ^/user/(.*)/moje.([0-9]+).html$ /moje.html?u=$1&showpage=$2 last;
>   rewrite ^/user/(.*)/(content|lista)/([0-9]+).html$ /moje.html?otheruser=$1&showpage=$3 last;
>   rewrite ^/user/(.*)/(content|lista).html$ /moje.html?otheruser=$1 last;
>   rewrite ^/user/(.*)/(+).html$ /$2.html?u=$1 last;
> 
> previously, at Apache, it was working fine (but a little bit slow, so we decide to move to nginx)

Try to move rewrites to specila location:

     location ^~ /user/ {
         rewrite ^/user/(.*)/moje.([0-9]+).html$
                 /moje.html?u=$1&showpage=$2      last;
         ...
     }

Also, it's better to use try_files instead of

     if (!-f $request-filename) { return 404; break; }

as here:

     location ~ \.html$ {
         try_files  $uri  /404.html;
         ...
     }

     location = /404.html {
         root /path/to/files;
     }


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





More information about the nginx mailing list