0

所以我想设置一些东西,以便所有请求都通过 index.php。

一些谷歌搜索给了我这个 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 执行任何操作?

4

1 回答 1

1

这应该有效;

<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>
于 2013-05-23T21:50:34.017 回答