简体   繁体   English

HTaccess Yii + PHP重写规则

[英]HTaccess Yii + PHP Rewrite Rule

I'm using Yii with normal PHP for a website 我正在将Yii和普通的PHP用于网站

My root directory 我的根目录

scripts (folder) -> 1.php index.html -> this is used to refer to the website. 脚本(文件夹)-> 1.php index.html->用于引用网站。 eg: www.abcd.com 例如:www.abcd.com

So when I need to refer to scripts, I generally do www.abcd.com/scripts/1.php 因此,当我需要引用脚本时,通常会执行www.abcd.com/scripts/1.php

Now, I'm planning to use Yii for a project. 现在,我打算将Yii用于一个项目。 scripts -> 1.php advanced -> frontend -> web -> index.php 脚本-> 1.php高级->前端->网络-> index.php

So now when I open www.abcd.com -> it should point to advanced/frontend/web/index.php and when I open www.abcd.com/scripts/1.php it should point to the same file I referred above in the root directory. 所以现在当我打开www.abcd.com->时,它应该指向advanced / frontend / web / index.php,而当我打开www.abcd.com/scripts/1.php时,它应该指向我上面提到的相同文件在根目录中。

How can I do that? 我怎样才能做到这一点?

Place the rewrite rule for the scripts before the general rule that goes to index.php and tell apache to ignore those urls. 将脚本的重写规则放在进入index.php的通用规则之前,并告诉apache忽略这些URL。

RewriteRule ^scripts/ - [L]

RewriteRule !^advanced/frontend/web /advanced/frontend/web%{REQUEST_URI} [L]

RewriteCond %{REQUEST_URI} ^/advanced/frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /advanced/frontend/web/index.php [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM