I have a PHP-based web app that I\'m trying to apply Apache\'s mod_rewrite to.
Original URLs are of the form:
http://example.com/index.php?page=home&x=5
Try this:.
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^/([a-z]+)(?:$|\?(?:.+)) /index.php?page=$1 [NC,L,B,QSA,NE]
B escapes the backreference (shouldn't be necessary since it is matching [a-z]+, but in case you want to extend it later, it might be useful).
EDIT: added RewriteCond. EDIT 2: QSA takes care of adding the ampersand.