您的位置:首页 > 运维架构 > Nginx

nginx上布置thinkphp

2016-05-11 17:07 621 查看
thinkphp config配置:

'URL_MODEL'          => '2', //URL模式


nginx rewrite配置:

location / {
set $static 0;
if  ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
root    /data/www;
set $static 1;
}
if (!-e $request_filename){
set $static 0$static;
}
if ($static = 00){
rewrite  ^/(.*)$  /index.php?s=$1  last;
}
}


如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称

location /yourdomain/ {
set $static 0;
if  ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
root    /data/www;
set $static 1;
}
if (!-e $request_filename){
set $static 0$static;
}
if ($static = 00){
rewrite  ^/yourdomain/(.*)$  /yourdomain/index.php?s=$1  last;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: