在本機 laragon 伺服器上的 nginx 上使用虛擬子網域是動態的

在本機 laragon 伺服器上的 nginx 上使用虛擬子網域是動態的

我有這個配置文件domain.beta.conf

server {
    listen 80;
    listen 443 ssl;
    server_name ~^(www\.)?(?<version>(.+\.))?domain.beta$ domain.beta
    root "X:/xx/www/domain"

    location / {
        try_files $uri $uri/ =404;
        autoindex on;
        rewrite ^/([^/]+)/?$ /$1.php last;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass php_upstream;      
        #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

}

我期望這些域能夠發揮作用

domain.beta
www.domain.beta

v1.domain.beta
v2.domain.beta
...
www.v1.domain.beta
www.v2.domain.beta
...

但有效的只是domain.beta如果我嘗試其他任何東西我會得到

www.domain.beta’s server IP address could not be found
v1.domain.beta’s server IP address could not be found
www.v1.domain.beta’s server IP address could not be found

我的nginx.conf

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    keepalive_timeout  32;
    proxy_connect_timeout  16000;
    proxy_send_timeout  16000;
    proxy_read_timeout  16000;
    send_timeout  16000;
    include "X:/xx/sites/nginx/sites-enabled/*.conf";
    client_max_body_size 1000M;
    server_names_hash_bucket_size 32;
}

但我也想從 php 方面捕獲它,$_GET['version']但我還無法到達,因為卡在這裡

我只是希望它能夠像重寫一樣工作,domain.beta/v1/但這沒有幫助,www.也不起作用

除了重寫網址之外,我對管理伺服器沒有任何背景知識

相關內容