[英].htaccess to redirect all requests to index.php
所以我想進行設置,以便所有請求都通過index.php。
一些Google搜索給了我這個mod_rewrite
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !(index\.php|public|css|js|robots\.txt)
RewriteRule ^ index.php [L,QSA]
</IfModule>
這可行。 但是,如果我真的命中index.php,我不希望它運行。 因此,我希望將www.domain / test當作www.domain / index.php / test來處理。
但是,如果我在瀏覽器中點擊www.domain / index.php / test,它應該做同樣的事情,但是它會重定向到某個地方的主文件夾。
我還讀到我不希望這種重定向在CSS,JS和機器人中發生。
如何使規則對index.php不執行任何操作?
這應該起作用;
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|css|js|robots\.txt|test)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.