A-A+

解决thinkphp在不支持pathinfo的nginx上的问题

2015年08月23日 Linux 暂无评论 阅读 4,709 views 次

最近使用thinkphp和redis写了一个仿微博的一个小项目,但是当部署到nginx服务器上时竟然都是404,经过百度才发现是因为nginx是不支持pathinfo。于是在网上找到了解决方案:

在项目的配置文件中加入

location / { 

    if (!-e $request_filename) { 

       rewrite ^(.*)$ /index.php?s=$1 last;  break; 

     } 

}

并且项目配置下url模式改为2:'URL_MODEL'=>2,

 

附上本人的配置文件:

server {

listen 80;

server_name redis.yanjiadong.net;

index index.php index.html;

root /alidata/www/redis;

location / {

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=$1 last; break;

}

}

location ~ .*\.(php|php5)?$

{

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{
expires 30d;

}

location ~ .*\.(js|css)?$

{
expires 1h;

}
access_log /data/log/access/redis.log;
}

 

 

给我留言

Copyright © 严佳冬 保留所有权利.   Theme  Ality 百度地图 苏ICP备19045515号-2

用户登录

分享到: