[英].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.