首先rewrite配置:
官网链接:https://www.kancloud.cn/manual/thinkphp6_0/1037488
apache服务器:
修改.htaccess文件如下(index.php后面加个?)
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
nginx服务器
修改nginx.conf 的 location / { } 部分(注意添加在location大括号的最前方)
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=/$1 last;
}
}
然后多应用配置
小伙伴们还是习惯原来的多应用目录吧?
这个是多应用配置的教程:
首先,在ide当中(我是idea)使用
cd tp
命令进入项目根目录
ide当中输入命令行
composer require topthink/think-multi-app
注意:重启nginx,清理浏览器缓存
在app目录下创建index目录
移动controller文件夹到新建的目录里面,同app目录内部的php文件不要动
如果还不行的话,使用命令行建立demo文件即可。(注意目录)
D:\phpstudy_pro\WWW\1029\tp>php think build demo
返回值:
Successed
多应用配置当中,应用配置的文件仍然在生效。
更改index.php内容,增加View支持
配置view
composer require topthink/think-view
否则会在View::fetch()
和View::assign('site', $site);
里面报错
然后,namespace
里面增加index
路径,
其他的比如think\Request
、think\facade\View
、think\facade\Db
等增加
namespace app\index\controller;
use app\BaseController;
use app\common\controller\FunctionsApp;
use think\facade\View;
use think\facade\Db;
//use think\db;
use think\Request;