How to remove the ".php" extension from URL and to internally redirect requests to the corresponding PHP file through .htaccess
To remove the ".php" extension from URLs and internally redirect requests to the corresponding PHP file using an .htaccess file, you can use Apache's mod_rewrite module. Here are the steps to achieve this:
Add the following code to your .htaccess file:
Options +FollowSymLinks
RewriteEngine On
# Remove the .php extension from URLs
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]