我设法使用.htaccess文件隐藏了frontend/web
和backend/web/
。但是urlManager无法理解这一点。我正在尝试创建类似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>
这是我在frontend/web
和backend/web
中使用的一个:
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
我使用这个.htaccess
配置,它对我来说很好。您只需要在站点根目录中有一个.htaccess
文件,并按说明设置前端/后端配置。也许这对你也有用。