Skip to content

Instantly share code, notes, and snippets.

@thomastuts
Created July 10, 2013 20:39
Show Gist options
  • Save thomastuts/5970109 to your computer and use it in GitHub Desktop.
Save thomastuts/5970109 to your computer and use it in GitHub Desktop.
Remove .php from extensions
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment