custom 404 nginx + php-fpm

shaktale nginx-forum at nginx.us
Thu Jul 30 22:04:43 MSD 2009


Probably yuo need somthing like this:

location ~ ^.+\.(js|jpe?g|gif|png|css)$ {
try_files $uri /index.php;
expires 1d;
}

loaction ~ ^/(.+)_(.+)/(.+)/$ {
fastcgi_pass 127.0.0.1:9000;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/index.php;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param PATH_INFO /action1/$1/action2/$2/action3/$3;
}

location ~ ^(/.+_.+/.+)([^/])$ {
rewrite ^(/.+_.+/.+)([^/])$ $1$2/ permanent;
}

location ~ ^.+\.php$ {
try_files $uri /index.php?$args;

fastcgi_pass 127.0.0.1:9000;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}

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


This works fine, thank you.

Is there any difference (in performance or so) if I do:


location / { 
    rewrite ^(/.+_.+/.+)([^/])$ $1$2/ permanent;
    try_files $uri /index.php?$args;
}



instead of:


location ~ ^(/.+_.+/.+)([^/])$ {
rewrite ^(/.+_.+/.+)([^/])$ $1$2/ permanent;
}


Thanks again.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4556,4628#msg-4628






More information about the nginx mailing list