How do I make a URL without .php run through PHP?

Would you like, for example, the URL www.bhosted.info/project to resolve to the script project.php? You can easily arrange this with a few lines in the .htaccess file in the root folder of your website:

RewriteEngine OnRewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]

Would you rather not use an .htaccess file? Then you can also create a folder in the root folder of your website. In the example above, you give this folder the name project. Then place the file index.php in that project folder.

Related articles