Or create .htaccess file in the root of your website and place this code inside:
RewriteRule ^([a-zA-Z0-9_-]+)$ $1.php [L]
If you already have .htaccess file, just append this code to it.
This will basically rewrite everything to the same thing plus ".php" so if you request yourwebsite.com/contact it will open yourwebsite.com/contact.php
The regex in this code doesn't match dot (.) so ordinary files (with extension) shouldn't be rewritten, e.g. if you request yourwebsite.com/contact.css it will serve it correctly, it won't load yourwebsite.com/contact.css.php
Note: This is .htaccess rule for Apache server with mod_rewrite support. It may work on other servers that support similar type of URI rewriting.