Welcome! Log In Create A New Profile

Advanced

custom 404 nginx + php-fpm

July 29, 2009 04:49AM
Hi all.

I have the folllowing config:

[code]
# static files without rewrite
location ~ ^.+\.(js|jpe?g|gif|png|css)$ {
# 404
try_files $uri /index.php;
expires 1d;
}

location / {
rewrite ^/(.+)_(.+)/(.+)/$ /index.php/action1/$1/action2/$2/action3/$3 last;
rewrite ^(/.+_.+/.+)([^/])$ $1$2/ permanent;

try_files $uri /index.php?$args;
}

# PHP
location ~ ^(.+\.php.*)$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;

include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
[/code]

I want to handle 404 errors with application (index.php).

Works fine, except urls with php files, ie mydomain.com/foo.php

The foo.php is passed to fcgi, and php-fpm returns "No input file specified."

If I use try_file in the "location ~ ^(.+\.php.*)$", then, the rewrites stops working. An error_page does not work either.

Any ideas ?

Thanks in advance.
Subject Author Posted

custom 404 nginx + php-fpm

shaktale July 29, 2009 04:49AM

Re: custom 404 nginx + php-fpm

Igor Sysoev July 29, 2009 05:06AM

Re: custom 404 nginx + php-fpm

shaktale July 30, 2009 02:04PM

Re: custom 404 nginx + php-fpm

Igor Sysoev July 30, 2009 02:28PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 197
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready