Convert lighttpd rewrite rule to nginx

Edho Arief edho at myconan.net
Tue Jul 24 06:43:03 UTC 2012


On Tue, Jul 24, 2012 at 1:08 PM, justin <nginx-forum at nginx.us> wrote:
> Thanks for the tip on removing the if block. So, perhaps the regular
> expression is off? Basically, the rewrite-rule should fire if the url
> does NOT contain a period.
>
> Examples:
>
>      /some/path   //should hit the rewrite rule
>      /file.php         //should NOT hit the rewrite rule
>
> Here is php.conf as well:
>
> location ~\.php {
>   try_files $uri =404;
>   fastcgi_index index.php;
>   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>   fastcgi_intercept_errors on;
>   fastcgi_pass 127.0.0.1:9000;
>   include /etc/nginx/fastcgi_params;
> }
>

I think instead of using rewrite, this should work:

location ~ ^[^.]+$ {
  fastcgi_intercept_errors on;
  fastcgi_param SCRIPT_FILENAME $document_root/controller.php;
  fastcgi_param PATH_INFO $uri;
  fastcgi_pass 127.0.0.1:9000;
  include fastcgi_params;
}

Alternatively, check this: http://nginx.org/r/fastcgi_split_path_info



More information about the nginx mailing list