Q:

using mod_rewrite to convert /?APP=XYZ&action=asdf&params=123 to /XYZ/asdf?params=123

I'm trying to setup a mod_rewrite that will allow for the following redirections:

my-domain/login => my-domain/?action=login
my-domain/login?param1=xyz&param2=asdf => my-domain/?action=login&param1=xyz&param2=asdf
my-domain/MYAPP/login => my-domain/?APP=MYAPP&action=login
my-domain/MYAPP/login?param1=xyz&param2=asdf => my-domain/?APP=MYAPP&action=login&params=xyz&param2=asdf

So far I have in my .htaccess file:
RewriteEngine On
RewriteRule ^([A-Z]*)/([a-z]*)$ ?APP=$1&action=$2 [L]

This seems to work for scenarios 3 and 4 however it fails to pass the $_GET['action'] value to my script in scenarios 1 and 2.
EDIT: Changed .htaccess to:
RewriteEngine On
RewriteRule ^([a-z]*)$ ?action=$1 [L,QSA]
RewriteRule ^([A-Z]*)/([a-z]*)$ ?APP=$1&action=$2 [QSA]

This seems to work.

A:

Question answered as above:
EDIT: Changed .htaccess to:
    RewriteEngine On
    RewriteRule ^([a-z]*)$ ?action=$1 [L,QSA]
    RewriteRule ^([A-Z]*)/([a-z]*)$ ?APP=$1&action=$2 [QSA]

