Remove .php extension with .htaccess

To remove the .php extension from a PHP file for example www.example.com/about.php to www.example.com/about you have to add the following code inside the .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Redirect 404 Not Found Page Using .htaccess

ErrorDocument 404 http://www.example.com/404      //404.php Page

.htaccess Rule from id to name

http://www.example.com/book-details.php?id=102 look like http://www.example.com/book/102

RewriteRule ^book/(.*)?$ /book-details.php?id=$1

Sample .htaccess Code

http://www.example.com/book-details.php?id=102 look like http://www.example.com/book/102

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

ErrorDocument 404 http://www.example.com/404      //404.php Page

RewriteRule ^book/(.*)?$ /book-details.php?id=$1