在 localhost laragon 服务器上使用 nginx 上的虚拟子域名来实现动态

在 localhost 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.也不起作用

除了重写 URL 之外,我对管理服务器没有任何背景知识

相关内容