1.将public下的index.php移到wwwroot根目录下,修改路径层级关系,将…/替换为/
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
namespace think;
require __DIR__ . '/vendor/autoload.php';
// WEB入口文件位置
define('PUBLIC_PATH','');
define('EXTEND_PATH', __DIR__ .'/extend/');
define('VENDOR_PATH', __DIR__ .'/vendor/');
// 执行HTTP应用并响应
$http = (new App())->http;
$response = $http->run();
$response->send();
$http->end($response);
2.在wwwroot下创建一个iis的伪静态配置文件,名称是web_config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url=".*\.(?:gif|jpg|png|css|js|txt|jpeg|swf|flv)" />
<action type="Rewrite" url="/public/{R:0}" />
</rule>
<rule name="Imported Rule 2">
<match url="/httpd(?:\.ini|\.parse\.errors)" />
<action type="CustomResponse" url="/" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^(?!/index.php)(?!/admin.php)(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
3.在域名管理下,域名解析:@ CNAME 虚拟主机上传的地址
4. 在主机管理中域名绑定
5. 在主机管理中设置php版本
注意: 设置首页设置为index.php
虚拟目录不用添加public