0

I'm looking to retrieve the ServerName field located in /etc/apache2/apache2.conf. My only issue is then calling it in PHP (echo $_SERVER['SERVER_NAME'];) it gives me not the server name but the ip address.

If I pull a phpinfo(); I can the server name under the Hostname:Port field under the apache2handler, so I know it's accessible somehow.

  • If you can not find it in $_SERVER['HTTP_SERVER_NAME'] perhaps consider that your Apache2/PHP configuration is not 'right'. – JavaRocky May 1 '10 at 3:08
  • But it shows up in phpinfo(), it can be found there somewhere. – Josh K May 1 '10 at 3:11
1

In PHP do a

var_dump($_SERVER);

or even

var_dump($_REQUEST);

Should help you. I have a feeling it is probably $_SERVER['HTTP_SERVER_NAME'] but do the above and it will tell you exactly

  • It's not in $_SERVER at all, I'll check $_REQUEST. – Josh K May 1 '10 at 3:02
  • Nope, nothing there either. This is similar to this other question I found but the answer is unclear. – Josh K May 1 '10 at 3:03
  • And you can't use HTTP_HOST? – Wizzard May 1 '10 at 3:32
  • In your phpinfo() output scroll downto "Apache Environment" section, is there anything in there? – Wizzard May 1 '10 at 3:34
  • Yeah, fixed it. Had something to do with UseConicalName or something. – Josh K May 1 '10 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.