tags:

views:

31

answers:

1

We have a site that resides on server A with the URL eg www.blah.com, however when it is live it will be accessed at the url eg www.notblah.com which will proxy the request to server A.

My question is, in PHP how does one properly work out the host and URI when the request is passed via a proxy? $_SERVER['host'] and $_SERVER['uri'] give me www.blah.com not the URL accessed via the proxy server.

+1  A: 

Try $_SERVER['HTTP_REFERER'] or check with phpinfo() if your proxy adds the original URL into the HTTP headers. Some do.

Gordon
I've done and some experimenting and was able to get the forwarded host using $_SERVER['HTTP_X_FORWARDED_HOST'] but there is no information on the forwarded URI - any ideas?
Mathew Attlee
Nope. Sorry. Your best bet is to use phpinfo and see if you can find the URL somewhere. Or, if you have access to the proxy, configure it to include the URL.
Gordon