提前模板Yii2 - 重定向使用htaccess的,以前端/网络 [英] advance template Yii2 - redirect to frontend/web using htaccess

查看:437
本文介绍了提前模板Yii2 - 重定向使用htaccess的,以前端/网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我使用的提前模板Yii2。而使用htaccess的重定向HTTP :: //mydomain.com到前端/ 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>

但是当我去到任何URL,即: http://mydomain.com/abc 。该网站始终指向首页。即使URL不是invailable ..

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 /前端/ 的根目录,

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆