In Nginx, I have a catch all set up like this:
server {
listen 80;
server_name *.example.com;
location / {
root /data/sites/www.example.com/widgets/public_html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ .php$ {
root /data/sites/www.examples.com/widgets/public_html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
And if I type abc.example.com it works. Now in PHP I need to the subdomain to be read. I am getting the subdomain like so:
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$urlSegments = parse_url($url);
$urlHostSegments = explode('.', $urlSegments['host']);
$subdomain = $urlHostSegments[0];
The problem is, instead of returning with abc as the subomain, it returns the *. So for PHP and NGINX, how can I get the actual subdomain with a catch all?