
如何配置nginx伪静态以支持ThinkPHP的PATHINFO模式
1个回答
展开全部
首先你的项目的config文件中要配置这一项
'URL_MODEL' => 2, // rewrite
在服务器中切换到nginx的安装目录,我这里是 /usr/local/nginx。然后添加thinkphp.conf 文件
vim /usr/local/nginx/conf/thinkphp.conf
内容如下
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=/$1 last;
}
}
然后在你的配置文件中include一下刚刚的配置文件。
如果你的ThinkPHP入口文件index.php不在根目录,则需要把thinkphp.conf改成这样
location /入口文件所在目录/ {
if (!-e $request_filename){
rewrite ^/abc/(.*)$ /abc/index.php?s=/$1 last;
}
}
'URL_MODEL' => 2, // rewrite
在服务器中切换到nginx的安装目录,我这里是 /usr/local/nginx。然后添加thinkphp.conf 文件
vim /usr/local/nginx/conf/thinkphp.conf
内容如下
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=/$1 last;
}
}
然后在你的配置文件中include一下刚刚的配置文件。
如果你的ThinkPHP入口文件index.php不在根目录,则需要把thinkphp.conf改成这样
location /入口文件所在目录/ {
if (!-e $request_filename){
rewrite ^/abc/(.*)$ /abc/index.php?s=/$1 last;
}
}

2023-12-06 广告
网易云信提供一站式的 1 对 1 UIKit 组件库,可以更快地搭建 1 对 1 社交平台,能够快速实现音视频呼叫、音视频通话、1对1消息发送、美颜和礼物功能,直接可以复用我们的组件源码就可以了。优势:1、全套1对1 UI组件,接入更快;2...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询