H
H
hrvasiliy2015-10-23 10:48:18
PHP
hrvasiliy, 2015-10-23 10:48:18

Why doesn't $_SERVER['SERVER_NAME'] return everything?

I am writing a router, I ran into the following problem:
when trying to return a subdomain, the function for some reason returns the main domain, but it does not see the subdomain. That is, when you try to do this on a site like: sub.domain.com

$sub = explode('.', $_SERVER['SERVER_NAME']);
echo $sub[0];

The $sub array contains domain and com, but there is no sub. I don’t understand what could be the matter, since with the same code on apache everything was in order.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
ldv, 2015-10-23
@hrvasiliy

serverfault.com/questions/496597/php-fpm-server-na...
use $_SERVER['HTTP_HOST']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question