Php Yii2:从UrlManger隐藏前端/web和后端/web

Php Yii2:从UrlManger隐藏前端/web和后端/web,php,.htaccess,yii2,Php,.htaccess,Yii2,我设法用.htaccess文件隐藏了frontend/web和backend/web/。但经理无法理解这一点。我试图创建类似于site/index的url,它应该是这样的:example.com/site/index,但它创建example.com/frontend/web/site/index 如何使用UrlManager解决此问题 更新:.htaccess在根目录中 Options -Indexes RewriteEngine on <IfModule mod_rewrite.c&g

我设法用.htaccess文件隐藏了
frontend/web
backend/web/
。但经理无法理解这一点。我试图创建类似于
site/index
的url,它应该是这样的:
example.com/site/index
,但它创建
example.com/frontend/web/site/index

如何使用
UrlManager
解决此问题

更新:.htaccess在根目录中

Options -Indexes
RewriteEngine on

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} admin
RewriteRule .* backend/web/index.php [L]

RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css)/
RewriteCond %{REQUEST_URI} !admin
RewriteRule .* frontend/web/index.php [L]
</IfModule>

我使用
.htaccess
config,它对我来说很好。您只需要站点根目录中的一个
.htaccess
文件,并按说明设置前端/后端配置。也许这也适用于您。

请添加您的.htacces规则use@Tony完成。你现在能帮我吗?这对我来说很有用,但当我点击“关于”链接时是这样的:“yii2_项目/frontend/web/index.php?r=site%2fauto”我想显示“yii2_项目/about”
RewriteEngine on

# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward the request to index.php
RewriteRule . index.php