![](/img/trans.png)
[英]Yii2 htaccess - How to hide frontend/web and backend/web COMPLETELY
[英]Yii2: Hiding frontend/web and backend/web from UrlManger
我設法使用.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
文件,並按照說明設置前端/后端配置。 也許這也會為您服務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.