我用yii2.0创建了一个网站。要打开网站的前端,我必须使用 localhost:8080/yii2/frontend/web/index.php要打开后端,我使用的是 localhost:8080/yii2/backend/web/index.php。
我的问题是我怎样才能像 http://localhost:8080/yii2/一样打开前端的网站对于本地主机:8080/yii2/frontend/web/index.php。
对于后端,我如何打开像 http://localhost:8080/yii2/backend/这样的网站本地主机:8080/yii2/后端/web/index.php
您正在寻找此 https://github.com/yiisoft/yii2/blob/master/docs/guide/tutorial-shared-hosting.md
简而言之,您必须将/web 文件夹移动到另一个位置并更改 index.php 和 index-test.php 中的路径。
1.你可以使用 Apache 或 nginx "use test.com" for localhost:8080/yii2/web/index.php
并使用"backend.test.com"表示本地主机:8080/yii2/backend/web/index.php
这是 Apache 中的 vhost.conf
<VirtualHost *:80>
DocumentRoot "C:phpstudywwwyii_2frontendweb"
ServerName dev.com
ServerAlias
<Directory "C:phpstudywwwyii_2frontendweb">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:phpstudywwwyii_2backendweb"
ServerName api.dev.com
ServerAlias
<Directory "C:phpstudywwwyii_2backendweb">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>