【发布时间】:2015-09-02 19:12:05
【问题描述】:
我已将这组指令添加到我的 Nginx 安装中
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
fastcgi_pass unix:/var/run/php5-fpm.sock;
# With php5-fpm:
include fastcgi.conf;
fastcgi_index index.php;
}
如果我联系http://myserverip/script.php,一切都会好起来的。 我需要使用重写引擎来重写一些 URL,在这个指令块之后我添加了许多其他块,如下所示:
location = /sentmessages {
rewrite ^(.*)$ /sent_messages.php break;
}
(我使用 winginx 转换器来实现 .htaccess 规则)
如果我联系http://myserverip/sentmessages,重写会顺利进行,但 PHP 脚本会被下载而不是传递给 FastCGI。 我不知道如何解决这个问题(试图更改指令的顺序但没有成功。)
如何解决?谢谢。
【问题讨论】:
-
删除
break并阅读文档
标签: .htaccess mod-rewrite nginx winginx