Skip to content

Instantly share code, notes, and snippets.

@ksaylor11
Created September 26, 2018 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksaylor11/db105746f7e1ba0ef4054d5ba8de6a09 to your computer and use it in GitHub Desktop.
Save ksaylor11/db105746f7e1ba0ef4054d5ba8de6a09 to your computer and use it in GitHub Desktop.
.htaccess rule for hiding .php extensions
# this is important!
Options FollowSymLinks
# Run Php without filename extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
# Return 404 if original request is .php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment