Skip to content

Instantly share code, notes, and snippets.

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 heyjoecampbell/660d2c10241cc8e8a632c819a7988267 to your computer and use it in GitHub Desktop.
Save heyjoecampbell/660d2c10241cc8e8a632c819a7988267 to your computer and use it in GitHub Desktop.
Remove .php File Extension and Force Trailing Slash (perfect for static Bootstrap websites)
## Remove .php -and- Force Trailing Slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(([^/]+/)*[^./]+)/$ $1.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment