找到Apache安装目录,打开
apache\conf\extra\httpd-vhosts.conf
复制下面代码,粘贴到末尾
<VirtualHost *:80>
DocumentRoot "项目的入口文件index.php所在的目录,例如:D:\Software\XAMPP\htdocs\Zerg\public"
ServerName 自定义域名,例如:lin.com
</VirtualHost>
之后找到 C:\Windows\System32\drivers\etc 下的hosts文件
在末尾添加 127.0.0.1 (空格 + 你设置的域名)例如:lin.com
重启服务器
配置前路径:
http://localhost/Zerg/public/index.php/sample/Test/hello
配置后路径:
http://z.cn/sample/Test/hello