• 冒险村物语
  • 英雄无敌3塔防
  • 驾考家园手游

解决ThinkPHP在Nginx下无法使用pathin方式的问题

2014-09-05

[环境]

Ubuntu 12.04 32bit

AMH面板 4.2

Nginx 1.4.4

PHP 5.3.27

ThinkPHP 3.1.2


--------------------------------- 不太华丽的分割线 ---------------------------------


其实就是直接写rewrite文件,具体的语法请百度之,我也不太懂,也是在网上半抄半改才勉强搞定的,rewrite内容在下面放出:

备注:我是直接在AMH上配置Nginx虚拟主机的,所以路径什么的可能会有些不同

在写rewrite之前先将原vhost下对应的网站配置中的location ~ */.php$ {}整个注释或删除(注意备份哦!!)


location / {

index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}

location ~ .*/.php
{
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_pass unix:/tmp/php-cgi-myar.kollway.com.sock;
fastcgi_index index.php;
include fcgi-host.conf;
fastcgi_param DOCUMENT_ROOT /web$subdomain;
fastcgi_param SCRIPT_FILENAME /web$real_script_name;
fastcgi_param PATH_INFO $path_info;

}


--------------------------------- 不太华丽的分割线 ---------------------------------


参考文章:

http://www.codesth.com/%E4%B8%8D%E7%94%A8rewrite%E5%85%BC%E5%AE%B9%EF%BC%8C%E8%A7%A3%E5%86%B3nginx%E4%B8%8D%E6%94%AF%E6%8C%81thinkphp-pathinfo%E6%A8%A1%E5%BC%8F/


http://blog.csdn.net/realghost/article/details/9082847

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)

人气推荐

知识阅读

精彩推荐

  • 游戏
  • 软件
查看更多>>