I am using following code to remove .php extension from URLs:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
My question is how to keep it removed just like stack overflow does. If my URL is domain.com/about.php it is redirected to domain.com/about but if someone types .php after about intentionally it remains there. Also, if someone directly visits domain.com/about.php it still remains there. How can I remove any extensions from URL just like stackoverflow does even if user types it intentionally? If this can't be done in .htacess can I do it in JavaScript or PHP?