I have over 8,000 Google URLs that I need to redirect
input URLs are like the following with unique cart_id and p_id
http://www.example.com/store/agora.cgi?cart_id=6497903.234477*8X3D96&p_id=16108&xm=on&ppinc=1a
My code:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/store/agora.cgi
RewriteCond %{QUERY_STRING} cart_id=[^\&]+\&p_id=([^\&]+)
RewriteRule ^(.*)$ http://www.example.com/store/agora.cgi?user2=yes&p_id=$1&xm=on&ppinc=1a [R=301,L]
Output I get:
http://www.example.com/store/agora.cgi?user2=yes&p_id=store/agora.cgi&xm=on&ppinc=1a
Output I want:
http://www.example.com/store/agora.cgi?user2=yes&p_id=16108&xm=on&ppinc=1a
As you can see the variable $1 is being assigned "store/agora.cgi" instead of "16108".
I tried $2 but that is null. The Regular Expressions - User Guide tells me that $1 should be assigned 16108 because that is the first submatch in the regular expression ([^\&]+).
I'm confused and need help.