THINKPHP nginx设置路由为PATHINFO模式

首先THINKPHP配置文件中设置

//url访问模式为rewrite模式
'URL_MODEL'=>'2',

然后再在nginx.conf文件中,找到这一条语句 #access_log logs/host.access.log main;
找到location /{}这个语句段落

location / {
index index.html index.htm index.php;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#地址作为将参数rewrite到index.php上。
#rewrite ^/(.*)$ /index.php/$1;
#若是子目录则使用下面这句,将subdir改成目录名称即可。
rewrite ^/company/(.*)$ /company/index.php/$1;
}
}
然后根据自己的路径重启nginx服务器
# path/nginx -s reload
posted @ 2017-03-20 18:03  周起  阅读(960)  评论(0编辑  收藏  举报