虚拟主机站点都是默认的
wwwroot
目录,需要网站访问默认指向到public
目录。
也可以在网站根目录下添加伪静态规则,将对应的访问直接调整到public
目录。
Apache
伪静态规则
修改安装目录中的httpd.confg
开启扩展:LoadModule rewrite_module modules/mod_rewrite.so
Directory 标签,AllowOverride none
设置为 AllowOverride All
wwwroot 目录下新建
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
IIS7
伪静态规则
wwwroot 目录下新建web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="public" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^/public/" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/public/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
伪静态配置可能不适用,还可以在主机控制面板点击设置首页功能,指定入口文件
public / index.php