Try this rule:-
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
OR
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
OR
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
If this global rules is not working for you then try below code also:-
In this code replace 'work'
with your project root directory.
RewriteEngine on
RewriteBase /work/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !\.php$
RewriteRule .* $0.php [L]
In linux you need to ON rewrite module.
open your terminal(ctrl+alt+t) and run this command.
sudo a2enmod rewrite
then restart apache2 by this command:-
sudo service apache2 restart
This tutorial link will help you.
Hope it will work for you :)