Get $_SERVER['SERVER_ADDR'] as 192.168 instead of 127.0.0.1?
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Get $_SERVER['SERVER_ADDR'] as 192.168 instead of 127.0.0.1?
I'm trying to get the $_SERVER['SERVER_ADDR'] as 192.168.abc.xyz though it keeps coming up at 127.0.0.1. The reason is I'm trying to make the base element echo out the server's IP on a local network so I don't have to change the IP manually every time the network changes. Obviously if I try to load the page up on a different system then it will attempt to load the files adding the base element's href attribute's value as being on the same system instead of the server. I've tried messing around in the hosts file (system32\drivers\etc) however nothing seemed to work there. All the threads on forums I keep coming across always burn out before anything useful. Suggestions please?
Re: Get $_SERVER['SERVER_ADDR'] as 192.168 instead of 127.0.0.1?
Hmm, maybe you have to change the IP in httpd.conf.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Get $_SERVER['SERVER_ADDR'] as 192.168 instead of 127.0.0.1?
Looks like you're correct though I'm not sure what dynamic value to place here...
I'm reading about the servername though I've never really found Apache's documentation understandable though if I find the answer I'll obviously post it here.
Code: Select all
ServerName localhost:80
#ServerName 192.168.1.101:80
#ServerName 127.0.0.1:80- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Get $_SERVER['SERVER_ADDR'] as 192.168 instead of 127.0.0.1?
Pilot error! I was not requesting from a network IP however once I did everything seemed to work fine. I commented out all my hosts and httpd.conf changes, restarted the Apache service, and everything runs clean. When I changed my network IP it still ran smoothly so I've resolved the issue.