Categories
Web Development

Make your .php extension optional

Place the following code in your .htaccess file to make the .php extension on your pages optional.

RewriteEngine on
# ----- make .php extension optional -----
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [QSA,L]
# ---- /make .php extension optional -----

Further suggestions on URL rewriting can be found these articles: