Skip to content

Instantly share code, notes, and snippets.

@bocharsky-bw
Created June 3, 2014 09:20
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 bocharsky-bw/8d537a052ddec9b59257 to your computer and use it in GitHub Desktop.
Save bocharsky-bw/8d537a052ddec9b59257 to your computer and use it in GitHub Desktop.
Rewrite all requests to the index.php script, except physical file or folder requests
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php/?(.*)\s [NC]
RewriteRule ^.*$ /%1%2 [R=301,L]
# if the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule ^.*$ index.php [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment