ThinkPHP6安装配置教程。所有项目前置操作-url(rewrite)重写、多应用配置

首先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\Requestthink\facade\Viewthink\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;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值