1. Configure virtual domain, open the apache / conf / extra / httpd-vhosts.conf file
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "F:\PHP\test\Multi-store-mall-ThinkPHP5.1\think\public"
ServerName mall.msm.cn #域名
ServerAlias malladmin.msm.cn #域名别名(配合TP5.1配置二级域名)
ErrorLog "logs/mall.msm.cn-error.log"
CustomLog "logs/mall.msm.cn-access.log" common
</VirtualHost>
2. Configure the local hosts file
127.0.0.1 mall.msm.cn
127.0.0.1 malladmin.msm.cn
3.apache open rewrite module, change the pseudo-static files under TP5.1 / public, hidden entry file index.php
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>
4.TP5.1 enable a second level domain name, change the route / route.php file
use think\facade\Route;
//配置tp5.1二级域名
Route::domain('mall', 'index'); mall.msm.cn指向index模块
Route::domain('malladmin', 'admin'); malladmin.msm.cn指向admin模块