Hi am getting an issue spinning this url - how do you escape it therefore it will correct itself?

The url was sent in to the public domain like so:

http://www.domain.com/directory/directory-2/10018485&key=3945

I have to write a guide to fix it:

http://www.domain.com/directory/directory-2/10018485?key=3945

` Am tring to get it done like so, with no success....

RewriteCond %{REQUEST_URI} \/directory\/directory-2\/10018485&key=3945
RewriteRule ^(.*)$ /directory/directory-2/?id=10018485&key=3945 [L]

Thanks :)

You don't have to escape the &lifier within the match to %26. That which you have works acceptable for me, unsure why it is not on your side. But you do not need a RewriteCond, you are able to mix the two right into a single rule. These work with me once the actual request is /directory/directory-2/10018485&key=3945 or directory/directory-2/10018485%26key=3945

RewriteRule ^directory/directory-2/10018485&key=3945$ /directory/directory-2/?id=10018485&key=3945 [L]

Inside a more abstract sense:

RewriteRule ^directory/directory-2/([0-9]+)&key=([0-9]+)$ /directory/directory-2/?id=$1&key=$2 [L]