提前模板 Yii2 - 使用 htaccess 重定向到前端/网络 [英] advance template Yii2 - redirect to frontend/web using htaccess
问题描述
现在我使用的是高级模板 Yii2.并使用 htaccess 将 http://mydomain.com 重定向到 frontend/web 文件夹.
Now I am using advance template Yii2. And using htaccess to redirect http:://mydomain.com to frontend/web folder.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(assets|css|js|ember)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^ember/(.*)$ web/ember/$1 [L]
RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js|ember)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ frontend/web/index.php/$1 [L,QSA]
#RewriteRule (.*) frontend/web/$1 [L]
</IfModule>
但是当我访问任何网址时,即: http://mydomain.com/abc .该站点始终指向主页.. 甚至 url 不可用..
but when I go to any url ie : http://mydomain.com/abc . the site always point to home page.. Even url not invailable..
提前致谢
推荐答案
这个 .htaccess 文件对我有用,你必须把这个 .htaccess 文件放在yii2advance/frontend/ 根目录,
This .htaccess file works for me, you have to put this .htaccess file under yii2advance/frontend/ root directory,
因此,当您访问 yii2advance.com/frontend/ 时,它会重写为 yii2advance.com/frontend/web
so when you access yii2advance.com/frontend/ it'll rewrite as yii2advance.com/frontend/web
RewriteEngine On
RewriteBase /
RewriteRule ^(.*) frontend/web/index.php/$1 [QSA,L,NC]
这篇关于提前模板 Yii2 - 使用 htaccess 重定向到前端/网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!