I want to hide .php extension so I wrote following code in .htaccess file which I found at this link How to remove file extension from website address?
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
This work fine when I type localhost/testsite/index it displays correctly localhost/testsite/index.php and display localhost/testsite/index in address bar as I want, but when I forcefully type localhost/testsite/index.php it does not converted to localhost/testsite/index. I want to remove extension even when user type .php after page name.