Yii2 Basic Template Remove /web

时间:2015-07-28 16:07:15

标签: yii2

Now I'm working on localhost:8080/basic/web. What I want to do it try to rewrite the url into localhost:8080/basic only. here is my .htaccess file

RewriteEngine on
# Change yourdomain.com to be your primary domain.

RewriteCond %{HTTP_HOST} ^(www.)?localhost:8080$

RewriteCond %{REQUEST_URI} !^/basic/web/

# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /basic/web/$1

RewriteCond %{HTTP_HOST} ^(www.)?localhost:8080$ 
RewriteRule ^(/)?$ basic/web/index.php [L]

Please help!!!

1 个答案:

答案 0 :(得分:3)

我建议三种方式:
1.将虚拟主机直接配置到web文件夹

<VirtualHost *:8080>
    DocumentRoot ".../basic/web"
    ServerName localhost
</VirtualHost>

2。在/basic文件夹

中创建一个htacess文件
RewriteEngine On
RewriteRule ^(.*)$ web/$1 [L]

3。将所有web文件夹移至webroot,如下所示:https://github.com/kartik-v/yii2-app-practical-b

相关问题