Pregunta

El ir fuera de mi otra cuestión y su par .

Estoy mirando para agarrar el valor Hostname:Port como se encuentra en la función phpinfo(). Me parece que no puede encontrar en cualquier lugar y de no en $_SERVER.

¿Fue útil?

Solución

You can use the $_SERVER['SERVER_NAME'] for this. You only need to configure the server accordingly that it returns the expected value. You're apparently using newer than Apache HTTPD 1.3.

You need to set UseCanonicalName directive to on in the <VirtualHost> entry in httpd.conf (also check the warning at the bottom of the linked document!).

<VirtualHost *>
    ServerName example.com
    UseCanonicalName on
</VirtualHost> 

Also see this answer.

Otros consejos

Apache 2.0 server with PHP 5.2 $_SERVER['SERVER_PORT'] should give you 80 for http connections.

For the hostname, for me these two work identically:

echo $_SERVER['HTTP_HOST'];
echo $_SERVER['SERVER_NAME'];

...should do the trick.

Read more about the $_SERVER variable here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top