【发布时间】:2018-07-04 16:48:29
【问题描述】:
我有一个 Nginx 网络服务器(我是 Nginx 的新手)。这是我的 Nginx 配置文件:
server {
listen 80;
listen [::]:80;
server_name example.com *.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_session_timeout 5m;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com *.example.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
我有一个允许通配符子域的 DNS 记录集。我现在的问题是:如何在 PHP 中“捕获”当前子域?
例如:如果子域是http://demo.example.com,我想去 http://example.com?subdomain=demo.
提前致谢!
【问题讨论】: