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


Htaccess Code not working after changing Server

我在htaccess中使用这段代码来剥离任何要索引的目录.php

RewriteRule ^.(index.+?'.php)$ /$1 [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 页是否有任何替代修改可以建议重新修改代码,以便在域之后和索引之前去除任何行或目录.php

要为文件夹创建异常administrator您可以执行以下操作:

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

如果我理解正确,这应该可以完成这项工作:

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

附言我喜欢这个工具来测试我的重写规则:链接