301/302 Redirect w/ URL Parameters

I have a number of blog articles that are still indexed but the title changed resulting in a 404 error on my site. I have installed plugin’s and done some standard 301/302 redirects but I am realizing I could do some optimization if I were to parse the incoming request for categorical redirects if the current site is no longer relavant.

For example, Google links to mysite.com/some-article/googlequery=cars.

I would like to take that mysite.com/some-article/googlequery=cars, parse ‘cars’, lookup one of my sites for cars from a db, then 301/302 to mycarsite.com/googlequery=cars. All this without losing the Google referer.

Real life example would be, Google for “sitepoint php”, click http://www.google.com/url?sa=t&rct=j&q=sitepoint%20php&esrc=s&source=web&cd=2&ved=0CDgQFjAB&url=http%3A%2F%2Fwww.sitepoint.com%2Fbooks%2Fphpant1%2F&ei=4DwnT72fC-LMiQLS9-iPAQ&usg=AFQjCNGWXJqpJ3M3qJSTuXz2zbp9ahEamA, parse out the q=sitepoint%20php, lookup another one of my sites for php, 301 to phpsite.com/q=sitepoint php, show the proper Google referer.

Maybe someone has a better idea than using a 301/302. My primary goal is to make sure the Google referers are passed correctly and the appropriate site type is shown for the query.

I guess maybe it isnt possible.

…but Google isn’t the referrer in the subsequent redirect.