For larger web projects I’ve moved almost exclusively to Django, but PHP is still handy. Recently I wanted to quickly (really quickly) make a flat-heirarchy site with dynamic pages, with clean urls like
I could do this with several directories containing index.php files, but I want to use the Google Maps API on several of these pages, and the separate directories would entail separate Google Maps API access keys – a pain.
First I added this .htaccess file to the docroot:
RewriteEngine On RewriteRule ^([a-z]+)$ /$1.php [P]
Then I created my page scripts as
bar.php and so forth; Apache mod_rewrite takes care of the rest.