Forum Moderators: phranque
RewriteEngine On
Options FollowSymLinks
# check if url ends in a slash and if it does redirect to same url without one
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*([^/.]+))/\ HTTP/
RewriteRule ^(([^/]+/)*([^/.]+))/$ http://localhost/example/$1 [R=301,L]
# extionless url rewrite for urls in form example.com/cmd
RewriteRule ^([^/.]+)$ index.php?cmd=$1 [L,QSA]
# extionless url rewrite for urls in form example.com/cmd/action
RewriteRule ^([^/]+)/([^/.]+)$ index.php?cmd=$1&action=$2 [L,QSA]
# extionless url rewrite for urls in form example.com/cmd/ajax
RewriteRule ^([^/]+)/([^/]+)/([^/.]+)$ index.php?cmd=$1&action=$2&ajax=$3 [L,QSA]
requests for robots.txt, images, stylesheets, and javascript files are also rewritten to be handled by your index file.