首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yii2:对UrlManger隐藏前端/web和后端/web

Yii2:对UrlManger隐藏前端/web和后端/web
EN

Stack Overflow用户
提问于 2015-07-05 17:01:40
回答 1查看 2.2K关注 0票数 2

我设法用.htaccess文件隐藏了frontend/webbackend/web/。但urlManager无法理解这一点。我正在尝试创建像site/index这样的url,它应该是这样的:example.com/site/index,但它创建了example.com/frontend/web/site/index

如何使用UrlManager解决此问题

更新:根目录中的.htaccess。

代码语言:javascript
复制
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/webbackend/web中使用的方法

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2015-07-05 20:48:08

我使用this .htaccess配置,它对我来说工作得很好。您的站点根目录中只需要一个.htaccess文件,并按照说明设置前端/后端配置。也许这对你也是有效的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31228730

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档