Currenty I have urls like this
www.mysite.com/index.php
www.mysite.com/test1/index.php
www.mysite.com/sample2/index.php
... many links
Now I removed directory structure and moved to
www.mysite.com/index.php
www.mysite.com/test1.php
www.mysite.com/sample2.php
... many links
Now I want to hide .php and add / so that old href links stays same like
www.mysite.com/test1/ ? 
After rewriting, if the url is www.mysite.com/test1/index.php, how to ingnore index.php at the end?