简体   繁体   中英

HTaccess Yii + PHP Rewrite Rule

I'm using Yii with normal PHP for a website

My root directory

scripts (folder) -> 1.php index.html -> this is used to refer to the website. eg: www.abcd.com

So when I need to refer to scripts, I generally do www.abcd.com/scripts/1.php

Now, I'm planning to use Yii for a project. scripts -> 1.php advanced -> frontend -> web -> 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.

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.

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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