Web Development

Remove .php from URLs [Snippet]

When making custom sites, I separate my code into various php files that each include a consistent header and footer so that I don’t have to deal with verbose, redundant HTML files. By default you end up with gross URLs like Make it by adding this to your .htaccess file and replacing index|about|.. with your own page names. There’s probably a more efficient way, but this works fine for small sites.

RewriteEngine On
RewriteRule ^(index|about|plans|app|features)/?$ $1.php?%{QUERY_STRING} [L]

If you do like verbose, redundant HTML files, I imagine you could just change the .php in the snippet above to .html. Enjoy!