.htaccess 301仅在主页上从index.php重定向

.htaccess 301仅在主页上从index.php重定向,.htaccess,mod-rewrite,redirect,http-status-code-301,.htaccess,Mod Rewrite,Redirect,Http Status Code 301,我需要将/index.php重定向到没有索引的主站点,但只在主页上。 我在htaccess中使用此代码 RewriteCond %{THE_REQUEST} ^.*/index\.php RewriteRule ^(.*)index.php$ /$1 [R=301,L] 但问题是,在管理面板中有一个路由需要index.php才能使页面正常工作。此规则是每次index.php出现在任何页面上时删除它。 我试着像这样添加行 RewriteCond %{REQUEST_URI} !^/AdminPa

我需要将/index.php重定向到没有索引的主站点,但只在主页上。
我在htaccess中使用此代码

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
但问题是,在管理面板中有一个路由需要index.php才能使页面正常工作。此规则是每次index.php出现在任何页面上时删除它。
我试着像这样添加行

RewriteCond %{REQUEST_URI} !^/AdminPanel/index\.php.*$
在重写规则之前,但它不会改变任何东西。

希望您能提供帮助。

从正则表达式中删除
*

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/index\.php
RewriteRule ^index\.php$ / [R=301,L]

我以多种方式组合了上面提到的行,但我无法让它正常工作。现在似乎正常工作了,非常感谢!我将在10分钟内将此标记为已接受:)