提前模板Yii2 - 重定向使用htaccess的,以前端/网络重定向、模板、网络、htaccess

2023-09-02 09:42:25 作者:我陪你度过漫长岁月

现在我使用的提前模板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]