getting server name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

getting server name

Post by pelegk2 »

when i use the $_SERVER['SERVER_name']
i am reciving the ip of the server i run on and not its name for example!!!
why is that?
thnaks i advance
peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Predefined Variables wrote:'SERVER_NAME'

The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
basically, http://localhost/blah.php -> localhost ; http://192.168.0.0/blah.php -> 192.168.0.0 ..
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

ok in my case i use the computers names

Post by pelegk2 »

i use the computers names as my server names!
how can i get the computer name?
thnaks in advance
peleg
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

you could prob get the computer name by using exec() somehow,
but i dont know what the command is


print_r($_SERVER);

see if theres anything you could use in there.

if you need to use names:
a- create a unique config file for each script, putting the corresponding server name into it
b- set up apache to use virtual hosts so you can name them

if u want to use virtual hosts and cant figure out how,
tell us what version of apache and what o/s your using and we can help.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

i remember that i've once explained how to do it for
windows 9x to xp and linux in the apache-iis section...
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

ok i have :

Post by pelegk2 »

apache 2.0.46 and php 4.3.2
i have apache 1 on : windows 2000 and 1 on windows 2003 server
so how do i configure virtual hosts for them>??can i config more then 1 domain on a pc?and how other users in my network - how here pc's will find each of the "domain" we configure?
and more then that
how can i redirect a certain "domain" from one serve to another?
thnaks i nadvance
peleg
Post Reply