0

My previous question got closed as those people did not quite understand my question.

I have a computer that hosts multiple domains. I have another computer that hosts another some other domains. Some of those domains are on both computers.

There IP addresses (both computers have multiple IP addresses) are unique to a particular computer.

A sub-domain only exists on one computer.

e.g. news.bbc.co.uk lives on computer A weather.bbc.co.uk lives on computer B

The domain being bbc.co.uk.

So the question is from news.bbc.co.uk -> how do I find the domain bbc.co.uk in PHP?

Ed Heal
  • 59,252
  • 17
  • 87
  • 127

3 Answers3

0

Computer A: 192.168.0.2 hosts news.bbc.co.uk

Computer B: 192.168.0.3 hosts weather.bbc.co.uk

For a script on Computer A to resolve "weather.bbc.co.uk", edit the hosts file on Computer A (/etc/hosts on Mac OS X/Unix, for Windows, Google to find where the hosts file is) and add the entry:

192.168.0.3        weather.bbc.co.uk

Leonard Teo
  • 1,238
  • 1
  • 17
  • 28
0

try using parse_url function in php for getting domain name

also check this previosuly answered link

Get domain name (not subdomain) in php

Community
  • 1
  • 1
Anish Joseph
  • 1,026
  • 3
  • 10
  • 24
0

If you know the list of domains against machines then why don't you do something like this?

$server_map = array(
    'news.bbc.co.uk' => 'A',
    'weather.bbc.co.uk' => 'B',
);
$path = parse_url('news.bbc.co.uk');
if(array_key_exists($path['path'], $server_map)) {
    $server = $server_map[$path['path']];
}

$server now contains the server letter you desire.

Treffynnon
  • 21,365
  • 6
  • 65
  • 98