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!!!
答案 0 :(得分:3)
我建议三种方式:
1.将虚拟主机直接配置到web
文件夹
<VirtualHost *:8080>
DocumentRoot ".../basic/web"
ServerName localhost
</VirtualHost>
2。在/basic
文件夹
RewriteEngine On
RewriteRule ^(.*)$ web/$1 [L]
3。将所有web
文件夹移至webroot,如下所示:https://github.com/kartik-v/yii2-app-practical-b