首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Yii2 .htaccess重定向到后端部分

Yii2 .htaccess重定向到后端部分
EN

Stack Overflow用户
提问于 2017-12-21 02:38:28
回答 1查看 323关注 0票数 0

我已经安装了Yii2高级应用程序,我现在要做的就是将这个url htpp://site/admin重定向到后端(管理)端。到目前为止,我尝试的是:

代码语言:javascript
运行
复制
AddDefaultCharset utf-8

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on


# Make the backend accessible via url: http://site/admin
RewriteRule ^admin$ $admin.php [L]

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

# otherwise forward it to index.php
RewriteRule . index.php


RewriteRule ^static - [L]

我不熟悉.htaccess,我也不太确定什么是正确的方式。这段代码是我在谷歌搜索后发现的。app/backend/web/.htaccess中包含.htaccess文件。你能给我指出正确的路吗?提前谢谢你!

EN

Stack Overflow用户

发布于 2017-12-27 03:12:01

简单:

代码语言:javascript
运行
复制
RewriteEngine On

# End the processing, if a rewrite already occurred
RewriteRule ^(frontend|backend)/web/ - [L]

# Handle the case of backend, skip ([S=1]) the following rule, if current matched
RewriteRule ^admin(/(.*))?$ backend/web/$2 [S=1]

# handle the case of frontend
RewriteRule .* frontend/web/$0

# Uncomment the following, if you want speaking URL
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^/]+/web)/.*$ $1/index.php
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47912419

复制
相关文章

相似问题

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