更改服务器后 Htaccess 代码不起作用

Htaccess Code not working after changing Server

我在 htaccess 中使用这段代码将任何目录剥离到 index.php

RewriteRule ^.(index.+?\.php)$ / [L,NC,R=301] 

例如

http://www.example.com/toys/index.php
http://www.example.com/battery/upload/index.php
http://www.example.com/xyz/photos/index.php

正在更改将所有这些重定向到

http://www.example.com/index.php

现在,当我更改服务器时 - 此代码导致 404 页 是否有任何替代修改可以建议重新修改代码,以便删除域之后和 index.php

之前的任何行或目录

如果我没理解错的话,这应该可以完成工作:

RewriteRule ^.+/index.php$ index.php [L,NC,R=301] 

P.S。我喜欢这个工具来测试我的重写规则:Link

要为 administrator 文件夹创建例外,您可以执行以下操作:

RewriteRule ^(?!administrator/).+?(index\.php)$ / [L,NC,R=301]