RewriteRule未重定向


RewriteRule not redirecting

由于请求,每个页面都需要以"index.php"为前缀;如果路径是第一个/it,那么现在它需要是/index.php/it.

我试过在settings.php中更改基本url。但它不起作用。尝试在.htaccess中重写。我已经尝试了以下代码

RewriteBase /
RewriteCond %{HTTP_HOST} ^http://www.example.com/index.php [NC]
RewriteRule ^(.*)$ http://www.example.com/index.php [L,R=301]

但它不起作用。请有人帮帮我。提前谢谢。。

确保已启用mod_rewrite并尝试使用此

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$ http://www.example.com/index.php/$1 [L,R=301]

请记住,$1是指您在URL 中捕获的(.*)

您没有使用捕获组(.*)。您可以使用$1 参考

RewriteRule ^(.*)$ http://www.example.com/index.php/$1 [L,R=301]