POST请求可以在以下配置下正常工作(不重定向到任何其他位置):
server {
listen 80 default;
client_max_body_size 108M;
root /app/public;
index index.php;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
location ~ \.php$ {
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}
}
一旦我将其移动到另一个位置-它就会停止工作(它只会重定向“ POST / v1 / notifications HTTP / 1.1” 301”):
server {
listen 80;
client_max_body_size 108M;
root /app/public;
index index.php;
location /v1/notifications {
alias /app/public;
index index.php index.html;
if (!-e $request_filename) {
rewrite ^.*$ index.php last;
}
location ~* "\.php$" {
fastcgi_pass php-fpm:9000;
index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}
}
#this is for another app container
location / {
proxy_pass http://application:80;
[.....];
}
}
有人有什么想法吗?应该添加……吗?或根本无法以这种方式工作。
答案 0 :(得分:1)
这是默认行为,因为/v1/notifications
现在映射到目录/app/public
。您可以通过用if
语句替换try_files
块来禁止默认行为。
例如:
location /v1/notifications {
alias /app/public;
index index.php index.html;
try_files $uri /v1/notifications/index.php;
location ~* "\.php$" {
...
}
}
有关详细信息,请参见this document。