I have a PHP page, main.php which is on server 1.
I have a PHP page main.php (same page, different code) on server 2.
main.php is a WebService.
I would l
If you have access to the Apache server config you can create a virtualhost with the following settings:
ProxyPreserveHost Off
ProxyPass / http://remotesite.domain.tld/
ProxyPassReverse / http://remotesite.domain.tld/
ProxyPassReverseCookieDomain remotesite.domain.tld proxysite.tld
You'll need to enable mod_proxy and mod_proxy_http for this. Substitute remotesite.domain.tld to the site you forward to, and proxysite.tld to the forwarder.
If you don't have access to the server config files, you can still do in php, by manually setting up curl and forward everything.
EDIT:
And of course the script must be in the root directory of a (sub)domain. And you should have a .htaccess that rewrites everything to it:
RewriteEngine On
RewriteRule .* index.php