Forum Moderators: phranque
Short version
I need to to add 500 to a variable I am using in my redirect eg if the variable is 150 it needs to be converted to 650
Long Version
I have replaced a shopping cart with a new one and obviously the links don't match up , BUT the real problem is that the variables don't match up any more
The old cart produced 2 different urls
one for first level categories (I have got this redirect working)
Old Store
[site.co.nz...]
New Store (800 is added to the category variable)
[site.co.nz...]
with this rule
RewriteCond %{QUERY_STRING} ^page_ID=1&cat_ID=([^/\.]+)?$
RewriteRule ^index\.php$ /sbo_shop/index\.php\?main_page=index&cPath=8%1 [R=301,L]
and it works fine
BUT
for the other URL for the next level of navigation
there are 3 variables involved
cat_ID easy to deal with just need to prefix it with an 8
pg_ID doesn't need changing it is fine
sub_ID -- I need to add 500 to the variable and this is what i can't figure out
eg
Old Store
[site.co.nz...]
New Store
[site.co.nz...]
Jim
It took me 2 days to figure out the first redirect so I think I'll just dump the sub and pg variable and make the redirect take the page to the first level category
But if you could provide me with a link to a tutorial that tells me how to pass a variable to an external script I'll definitly have a look at it
The other thing is and i'm not sure if i should start a new thread for this is this bit
cat_ID=([^/\.]+)?$
Thanks for the help JDMorgan
RewriteCond %{QUERY_STRING} ^page_ID=1&cat_ID=([0-9]+)$
RewriteRule ^index\.php$ http://example.com/shop/index\.php\?main_page=index&cPath=8%1 [R=301,L]
#
RewriteCond %{QUERY_STRING}>50 ^cat_ID=([0-9]+)&sub_ID=([0-9])&pg_ID=([0-9]+)&page_ID=2>(50)$ [OR]
RewriteCond %{QUERY_STRING}>5 ^cat_ID=([0-9]+)&sub_ID=0?([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(5)$ [OR]
RewriteCond %{QUERY_STRING}>6 ^cat_ID=([0-9]+)&sub_ID=1([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(6)$ [OR]
RewriteCond %{QUERY_STRING}>7 ^cat_ID=([0-9]+)&sub_ID=2([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(7)$ [OR]
RewriteCond %{QUERY_STRING}>8 ^cat_ID=([0-9]+)&sub_ID=3([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(8)$ [OR]
RewriteCond %{QUERY_STRING}>9 ^cat_ID=([0-9]+)&sub_ID=4([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(9)$ [OR]
RewriteCond %{QUERY_STRING}>10 ^cat_ID=([0-9]+)&sub_ID=5([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(10)$ [OR]
RewriteCond %{QUERY_STRING}>11 ^cat_ID=([0-9]+)&sub_ID=6([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(11)$ [OR]
RewriteCond %{QUERY_STRING}>12 ^cat_ID=([0-9]+)&sub_ID=7([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(12)$ [OR]
RewriteCond %{QUERY_STRING}>13 ^cat_ID=([0-9]+)&sub_ID=8([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(13)$ [OR]
RewriteCond %{QUERY_STRING}>14 ^cat_ID=([0-9]+)&sub_ID=9([0-9]{2})&pg_ID=([0-9]+)&page_ID=2>(14)$
RewriteRule ^index\.php$ http://example.com/shop/index.php?main_page=index&cPath=8%1_%4%2_%3 [R=301,L]
If this doesn't meet your needs, then using a script to re-arrange the query and then call your new shopping cart, or using a RewriteMap script as theBear suggests, will be your best bet.
Jim