> TP6.0中的路由省略應(yīng)用名只能用`入口文件綁定應(yīng)用` 和 `域名綁定應(yīng)用`,經(jīng)過測試,最后得出`域名綁定應(yīng)用`是最合適的部署方式。如果有更好的部署方案,歡迎分享。QQ:[23426945](http://wpa.qq.com/msgrd?v=3&uin=23426945&site=qq&menu=yes "23426945") #### 1. 下載TP6.0,引入多應(yīng)用模式擴展 --- ``` composer create-project topthink/think tp6 composer require topthink/think-multi-app ``` #### 2. 配置多個虛擬域名(多個域名用于域名綁定應(yīng)用) --- **apache虛擬主機配置文件:`conf/extra/httpd-vhosts.conf` 添加以下內(nèi)容** <VirtualHost *:80> DocumentRoot "E:\www\thinkphp\tp6\public" ServerName tp6.cy ServerAlias liang.tp6.cy admin.tp6.cy </VirtualHost> **本地路由表:`C:/Windows/System32/drivers/etc/hosts` 域名映射IP** 127.0.0.1 tp6.cy 127.0.0.1 liang.tp6.cy 127.0.0.1 admin.tp6.cy #### 3. 此時三個域名都可以用于訪問 --- ![](https://img.itqaq.com/art/content/5a2ca05eee1ced700f9b03da5ff8ae19.png) #### 4. 域名綁定應(yīng)用 --- **修改配置文件:`config/app.php`** ``` // 域名綁定(自動多應(yīng)用模式有效) 'domain_bind' => [ '*' => 'index', 'liang' => 'admin', 'admin' => 'admin', ], ``` **此時 `tp6.cy` 綁定到了 `index應(yīng)用`,`liang.tp6.cy` `admin.tp6.cy` 綁定到了 `admin應(yīng)用`** ![](https://img.itqaq.com/art/content/1ca34f3b263d57b15232aa86ba5f84b7.png) #### 5. 復制 layuiadmin 單頁版的 `src`、`start` 目錄 --- ![](https://img.itqaq.com/art/content/4d23264f40ec74108f9818532cfe59d2.png) #### 6. 在TP6.0的public目錄下新建一個admin目錄,并將layuiadmin資源放進去 --- ![](https://img.itqaq.com/art/content/3c01b8454d24212d6fc0694444a611a1.png) **修改宿主頁面中的路徑、配置實時刷新緩存** ![](https://img.itqaq.com/art/content/d3b48d1923346e2f082a082210df47b3.png) #### 7. admin應(yīng)用index控制器的index方法重定向到layuiadmin宿主頁面 --- **添加重定向** ![](https://img.itqaq.com/art/content/251e1d6e397a5bee026a83ff37e7731a.png) **訪問綁定到admin應(yīng)用的域名,自動重定向到layuiadmin** ![](https://img.itqaq.com/art/content/a6be03ce8639ff9be4f866a592dd5231.png)