By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,644 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

Getting value of servername in <VirtualHost>

P: n/a
Hi,

I'm using PHP 4.4.4 with Apache 2. How would I get the value of the
"ServerName" attribute of the "<VirtualHostdirective in the Apache
configuration (httpd.conf) file?

I noticed that "$_SERVER['SERVER_NAME']" is not the answer to this
question because we have multiple domains pointing to the same IP, and
"echo $_SERVER['SERVER_NAME']" always yields a value typed in the
browser's address bar.

Thanks, - Dave

Jul 27 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jul 27, 4:07 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.comwrote:
Hi,

I'm using PHP 4.4.4 with Apache 2. How would I get the value of the
"ServerName" attribute of the "<VirtualHostdirective in the Apache
configuration (httpd.conf) file?

I noticed that "$_SERVER['SERVER_NAME']" is not the answer to this
question because we have multiple domains pointing to the same IP, and
"echo $_SERVER['SERVER_NAME']" always yields a value typed in the
browser's address bar.

Thanks, - Dave
Hi, the $_SERVER['SERVER_NAME'] should do it...it should return
whatever is in your ServerName field, I thought... You could always
try making a test script with print_r($_SERVER); which will just print
all of the values in the $_SERVER array, then just look through to see
if one of the keys contains the info being sought. Sorry I am not
very much help here.

Jul 27 '07 #2

P: n/a
On Jul 27, 4:15 pm, davidkru...@techie.com wrote:
On Jul 27, 4:07 pm, "laredotorn...@zipmail.com"

<laredotorn...@zipmail.comwrote:
Hi,
I'm using PHP 4.4.4 with Apache 2. How would I get the value of the
"ServerName" attribute of the "<VirtualHostdirective in the Apache
configuration (httpd.conf) file?
I noticed that "$_SERVER['SERVER_NAME']" is not the answer to this
question because we have multiple domains pointing to the same IP, and
"echo $_SERVER['SERVER_NAME']" always yields a value typed in the
browser's address bar.
Thanks, - Dave

Hi, the $_SERVER['SERVER_NAME'] should do it...it should return
whatever is in your ServerName field, I thought... You could always
try making a test script with print_r($_SERVER); which will just print
all of the values in the $_SERVER array, then just look through to see
if one of the keys contains the info being sought. Sorry I am not
very much help here.
Good thought, but both $_SERVER['SERVER_NAME'] and
$_SERVER['HTTP_HOST'] contained what was in the browser's address
field, which was different than what was in my <VirtualHost>
ServerName.

Thanks though, - Dave

Jul 27 '07 #3

P: n/a
la***********@zipmail.com wrote:
I'm using PHP 4.4.4 with Apache 2. How would I get the value of the
"ServerName" attribute of the "<VirtualHostdirective in the Apache
configuration (httpd.conf) file?
Are you able to edit the httpd.conf file? If so, look at the
UseCanonicalName directive.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 37 days, 1:58.]

Cryptography Challenge
http://tobyinkster.co.uk/blog/2007/0...pto-challenge/
Jul 27 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.