.htaccess删除文件扩展名但找不到查询文件

When I use this code the URL is would it should be but it errors saying 'The requested URL /search was not found on this server.' this is because now the '.php' is not there but I don't know what is know needed to fix this

.htaccess file

RewriteEngine on
ErrorDocument 404 http://localhost/project/

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]