背景
今天将写好的Vue单页部署到ThinkPHP6入口时出现无法首页空白问题。
我需要的就是访问域名直接访问Vue页面,后台只做API服务
尝试将入口文件index.html执行优先级提高到index.php之前。测试无效
一般这种情况只要配置两个域名:一个前端访问,一个api服务器,就可以搞定了,但是我的前端页面非常简单,还需要解析一个域名就很烦。
解决方式
由于tp默认的控制器为Index/index, 而我就是需要访问时首页就是Vue页面,那么直接指定Index->index 解析到同目录的index.html就可以了
<?php
//Index->index.html
namespace app\controller;
use app\BaseController;
use think\facade\View;
class Index extends BaseController
{
    public function index()
    {
        return View::fetch('index.html');
    }
}
Thinkphp6的 Nginx 伪静态配置
location / {
    if (!-e $request_filename){
        rewrite  ^(.*)$  /index.php?s=$1  last;   break;
    }
}文件目录


