Skip to content

Instantly share code, notes, and snippets.

@chrislaskey
Last active December 17, 2015 17:09
Show Gist options
  • Save chrislaskey/5643725 to your computer and use it in GitHub Desktop.
Save chrislaskey/5643725 to your computer and use it in GitHub Desktop.
Apache .htaccess configuration for auto-appending `.php` filename extension.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
# The two RewriteCond rules are boilerplate, they make sure files that exist
# on the server (CSS, JS, images, etc) will not have their URLs rewritten and
# be served directly.
# The RewriteRule captures all remaining URL requests, and adds a .php to the end.
# The [QSA] flag ensures about.php does not become about.php.php.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment