Sorry, forgot to include the mailing list email when I replied to this originally...

On Aug 28, 2010, at 8:28 PM, tedd wrote:

Sorry for not making sense. But sometimes you have to confirm the players (both server and remote) in communications.

Try this -- place this script on your site:


You will note that:

[SERVER_NAME] => is the domain name of your site.


[SERVER_ADDR] => is the IP of your site. If you are on a shared host, then it will still be the IP of the main host.

Please note:

[REMOTE_ADDR] => is the IP of the remote server. It *will be* the IP of the remote main host regardless of if the requesting script is running on the remote main host OR is running under a remote shared host.

Here's an example:

My site is running on a shared host.

The server address reported for this site is:

However, if I enter into a browser, I do not arrive at, but instead go to who is my host.

Now, if was the requesting script, how could the original script know what domain name the request came from? As it is now, it can only know the main host ID, but not the domain name of the requesting script. Does that make my question any clearer?

So my questions basically is -- how can I discover the actual domain name of the remote script when it is running on a shared server?

I hope that makes better sense.



I really don't understand what you mean by "remote script" -- most requests are made by clients. REMOTE_ADDR is the IP address of the *client* - i.e. the requesting system. It may or may not be a script. And it may or may not have an accessible hostname.

Is this a situation where you are establishing a service that is to be called by other servers, i.e, some form of API? If not, and if it is a case of a browser client calling a PHP script on your server, most browser clients aren't running on very useful hostnames for the outside world anyway. E.g. the hostname of my mac is "paladin.local" but it obviously can't be called by the outside world by that name. Maybe tell us what you are trying to accomplish by knowing the hostname of the calling machine? Maybe there's another way.

Are you trying to set up two-way communication between the two servers? Normally, communication is established without regard for the calling machine's hostname, because it's going through the connection established by the web server. PHP just returns info along that connection to the calling machine. It seems you would only need to know the requesting system's hostname if you were going to establish some other channel of communication with it, i.e., if your original script was somehow going to call back the calling machine, to do some other kind of activity. If that *is* what you're doing, I can probably guarantee there's a better way to do it.

However, if what you're after is *authenticating* that the requester is who they say they are, there are ways to do that as well without knowing the requesting host's name (and better than knowing the requesting host's name, you can establish authenticity and access control for a particular script which is much better than just establishing blanket authority for a particular hostname).

However, I'm really reaching here with trying to understand what you want to accomplish by knowing the requesting machine's hostname.

So, please, explain what you are trying to do and maybe we can help with that.


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to