Skip to content

Instantly share code, notes, and snippets.

@terryupton
Created May 28, 2014 11:34
Show Gist options
  • Save terryupton/b638ab6ad75723ba7ecd to your computer and use it in GitHub Desktop.
Save terryupton/b638ab6ad75723ba7ecd to your computer and use it in GitHub Desktop.
Remove .php extension in HTAccess
# ------------------------------------------------------------------------------
# | Remove .php-extension from urls |
# ------------------------------------------------------------------------------
#This removes php extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)/$ $1.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment