【发布时间】:2015-12-29 06:31:22
【问题描述】:
我的 nginx 服务器上使用 php-fpm 有一堆不同的规则。
最简单的是重写,使用
将 http://server/$1?param=1 更改为 http://server/$1.php?param=1location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
我还需要将 http://server/abc/123 重写为 http://server/abc.php/123 并由 php-fpm 处理
这是fast-cgi代码:
location ~ [^/]\.php(/|$) {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
这是位置重写
location @abc-php {
rewrite ^(.*)/abc/(.*)$ $1/photo.php/$2 last;
}
但我不断收到 404。我不确定哪里出错了,我们将不胜感激。
【问题讨论】: