remove .php extension from url using .htaccess let’s have start with creating .htaccess file.
Create .htaccess file to root of the your projects. add below code inside file.
Which allow to run without extension.
.htaccess
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteRule ^(.*)$ $1.php [NC,L] this line remove the extension.
RewriteCond %{REQUEST_FILENAME} !-d this will check if request is URL not directory
RewriteCond %{REQUEST_FILENAME}.php -f This will check the file without the extension
You can do similar with .html as well. this will allow the html file to run without extension.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]