'Php extension hiding for pages htaccess [duplicate]

In my website abc.xyz if somebody tries to access a page abc.xyz/about-us.php they are redirected to abc.xyz/about-us. But if you enter a random url abc.xyz/vdsv or abc.xyz/about-us/cdasdf they are redirected to 404 page which should happen like that only, but if somebody tries to use the url abc.xyz/about-us.php/brfgbdrf they are sent back to the about us page and not 404. If somebody tries to use inappropriate url they should be redirected to 404 page. What should I do I am using following code in my htaccess file

RewriteBase /
RewriteRule ^(.+)\.php$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [NC,END] 

# Remove trailing slash in the end
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

Please suggest what should I do



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source