Home  >  Article  >  php教程  >  nginx+thinkphp下解决不支持pathinfo模式

nginx+thinkphp下解决不支持pathinfo模式

WBOY
WBOYOriginal
2016-06-06 20:02:38873browse

这篇文章主要介绍了nginx+thinkphp下解决不支持pathinfo模式的相关资料,需要的朋友可以参考下

nginx环境问题弄了两天,发现网上很多人的帖子要么复制粘贴,要么就是没有结贴,还自己写一句“哈哈,我自己解决了”之类的,这点我就鄙视这些发帖的同胞了,你说你问题问了,问题解决了也不给个解释。还在搜索的前几页,想没想过需要答案的人的感受呢。满心欢喜的去看答案,发现没有结贴。好吧,不多说,进入正题。

我这种方式是不需要将URL_Model改为rewrite/兼容的:

大约第43行,按照下面的对照自己的code进行修改,请注意细节的符号:

location / { root C:/Zend/workspaces; #//这是你自己项目的根目录。 index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 break; break; } }

在php的配置中,将location ~ \.php$ 改为 location ~ \.php,再次强调,注意细节,这里去掉了$符号,我刚开始也是因为这个原因一直没能解决。

location ~ \.php { root C:/Zend/workspaces; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME C:/wnmp/php$fastcgi_script_name; include fastcgi_params; set $path_info ""; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; }

如果仍未解决,在ThinkPHP入口文件index.php中加入配置define(‘_PHP_FILE_',$_SERVER['SCRIPT_NAME']);

期间大家可能会遇到500,404的问题,但记住一点,细心就行。只要按照我这个改,基本没什么问题。如果还有问题,欢迎留言咨询。

以上所述就是本文的全部内容了,,希望大家能够喜欢。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn