regex - htaccess redirect with bad formated query string -


i'm trying redirect url bad formatted query string generated joomla.

the url /index.php?/some-string/ (notice absence of regular parameter ?x=) 1 of following:

/some-string 

or

/index.php?q=/some-string/ 

i tried redirect 301 /index.php?/some-string/ /some-string redirect /?%2fsome-string%2f=

i tried replacing ?/ ?q=/ without success.

maybe this?

rewriteengine on  rewritecond {the_request} \ /+index\.php\?(?:q=|)([^&\ ]+) rewriterule ^ /%1? [l,r]  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.+)$ /index.php?q=$1 [l,qsa]