The easiest method I can think of is to use mod_proxy (if using apache on the client's domains)
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Another way is to have a php script proxy the data:
<?php
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);1
/* Sends an http request to www.example.com
with additional headers shown above */
$fp = fopen('http://www.example.com/app?q='.$_GET['q], 'r', false, $context);
fpassthru($fp);
fclose($fp);
?>
If you can add a .htaccess, I would advise using .htaccess to redirect everything from app on using something similar to:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
You may have to do some tweaking for it to reside in /app. And then your wrapper script will have to learn to pass on the q=$1 variable to the host in a different way. My example is pretty raw and it's not checked for errors.
I'd also send a fixed query per site, with the domain. That way it's easier for your app to decipher where it's coming from and won't have to rely on IP addresses and such.
Also, you'll have to deal with sessions too, as the wrapper as shown is not passing cookies all the way down to the client and back. And the abc.com domain is only going to see the IP of the server hosting the wrapper script.