Nginx重写下载php文件而不是执行

我想重写一些与Nginx的链接,但PHP文件下载而不是执行,如果我在浏览器中运行PHP文件正在工作,所以没有fastcgi的问题。

我已经在这里查了其他类似的问题,但没有任何帮助。

我的nginx.conf文件

.... location / { location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ { expires max; } location ~ [^/]\.php(/|$) { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9002; fastcgi_index index.php; include /etc/nginx/fastcgi_params; } } location ~* "/\.(htaccess|htpasswd)$" { deny all; return 404; } location /contact { rewrite ^/contact/?$ /contact.php last; } 

我需要重写contact.php /联系,但不工作。

我也试过:

  location /contact { rewrite ^/contact?$ /contact.php last; } location /contact { rewrite ^/contact$ /contact.php last; } location /contact { rewrite ^/contact?$ /contact.php break; } 

没有任何工作 我没有这个问题是过去… … –

我发现这个问题,我刚刚replace:

 location /contact { rewrite ^/contact?$ /contact.php last; } 

 rewrite ^/contact? /contact.php last;