本文介绍了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重定向到后端部分
发布评论