Htaccess Code not working after changing Server

109 views Asked by At

I was using this code in htaccess to strip any directory to index.php

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

For instance

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

It was changing redirecting all of them to

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

Now when i changed my server - this code is causing 404 pages Is there any alternate modification which can be advised to remodify the code so as to strip any line or directory after domain and before index.php

2

There are 2 answers

1
anubhava On BEST ANSWER

To create exception for administrator folder you can do:

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

If I understood you correctly, this should do the job:

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

P.S. I like this tool to test my rewrite rules: Link