Mod_rewrite (htaccess) QSA and removing charactes from appended query string

I've been struggling with some htaccess redirects. I just spent some time reading and searching and couldn't get a solution that works with my scenario.



I'm in the process of making the 301 redirect for an old website (ASP) to a new one (Wordpress). The old pages has parameters query which I need to process but also remove 'http://' string from it to get redirect to work.



Example URL (old) to redirect looks like:



http://www.domain.org/index.asp?documentID=2410&utm_source=IT+Travel+Reminder&utm_medium=Informz%2FnetFORUM&utm_campaign=IT%2FTravel+Reminder%2FMonthly+Monthly+Travel+Reminder&zbrandid=4050&zidType=CH&zid=28841368&zsubscriberId=1036792259&zbdom=http://my.informz.net


redirected to:



http://www.domain.org/permalink-2410/?qs=true&utm_source=IT+Travel+Reminder&utm_medium=Informz%2FnetFORUM&utm_campaign=IT%2FTravel+Reminder%2FMonthly+Monthly+Travel+Reminder&zbrandid=4050&zidType=CH&zid=28841368&zsubscriberId=1036792259&zbdom=my.informz.net


and .htaccess code to redirect it:



RewriteCond %{QUERY_STRING} ^documentid=2410(&.*)$ [NC]
RewriteRule ^index\.asp(.*):(.*)$ http://www.domain.org/permalink/?qs=true%1%2 [L,R=301,QSA]


but somehow is not working as I have expected when



RewriteCond %{QUERY_STRING} ^documentid=2410(&.*)$ [NC]
RewriteRule ^index\.asp$ http://www.domain.org/permalink/?qs=true%1 [L,R=301,QSA]


works fine when I will remove http:// or : from a query string.



Where do I have made mistake?



Thanks!



Answers

Try this rule:



RewriteCond %{QUERY_STRING} ^documentid=(\d+)(&.+?)http://(.+)$ [NC]
RewriteRule ^index\.asp$ http://www.domain.org/permalink-%1/?qs=true%2%3 [L,R=302,NC,NE]


Make sure to clear browser cache before testing this.