Yii2 .htaccess重定向到后端部分

编程入门 行业动态 更新时间:2024-10-25 20:20:36
本文介绍了Yii2 .htaccess重定向到后端部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have installed Yii2 advanced app and what i am trying to do now is to redirect this url htpp://site/admin to the backend ( admin ) side. What i tried so far is:

AddDefaultCharset utf-8 Options +FollowSymLinks IndexIgnore */* RewriteEngine on # Make the backend accessible via url: 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 并不熟悉,我不确定什么是正确的方法。这段代码是我在谷歌搜索后发现的。 .htaccess 文件位于 app / backend / web / .htaccess 中。你能指出正确的方法吗?

I am not familiar whit .htaccess and i am not pretty sure what is the right way. This code is what i found after googling. The .htaccess file is in the app/backend/web/.htaccess. Can you point me the right way? Thank you in advance!

推荐答案

简单:

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

更多推荐

Yii2 .htaccess重定向到后端部分

本文发布于:2023-10-31 16:39:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546664.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   后端   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!