PHP-FPM和Nginx重写导致下载 [英] PHP-FPM and Nginx rewrite causing download
本文介绍了PHP-FPM和Nginx重写导致下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一台设置PHP-FPM的Nginx HTTP服务器,几乎所有东西都可以正常工作.我希望能够转到path/to/file
,它给了我index.php?url=path/to/file
,它确实如此.但是,它会下载实际的PHP,但不会在浏览器中执行它.我不确定是什么原因造成的.
I have an Nginx HTTP server with PHP-FPM set up and almost everything works fine. I want to be able to go to path/to/file
and it give me index.php?url=path/to/file
, which it does. However, it downloads the actual PHP, it won't execute it in the browser. I'm not sure what is causing this.
Nginx配置:
server {
listen 80;
server_name sandbox.domain.tld;
access_log /path/to/domain/log/sandbox.access.log;
error_log /path/to/domain/log/sandbox.error.log;
location / {
root /path/to/sandbox;
index index.php;
if (!-e $request_filename) {
rewrite ^/beta/(.+)$ /beta/index.php?url=$1 break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/sandbox$fastcgi_script_name;
}
推荐答案
尝试更改
rewrite ^/beta/(.+)$ /beta/index.php?url=$1 break;
至
rewrite ^/beta/(.+)$ /beta/index.php?url=$1 last; break;
应该让nginx重新读取URI并进行相应处理.
Which should get nginx to re-read the URI and process it accordingly.
这篇关于PHP-FPM和Nginx重写导致下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文