Nginx子域和指向根目录中相同文件的域

Nginx子域和指向根目录中相同文件的域,nginx,Nginx,我有my-domain.com和prod.my-domain.com,我已经为这两个网站创建了以下配置设置 prod.my-domain.com my-domain.com 但是,无论我输入哪个URL,都会将my domain.com的所有文件存储在哪里。 我想在访问时查看root/usr/share/nginx/index/html/prod/的内容 prod.my-domain.com但是,我需要根目录/usr/share/nginx/index/html/根目录在位置/的两种服务器配置中都

我有my-domain.com和prod.my-domain.com,我已经为这两个网站创建了以下配置设置

prod.my-domain.com my-domain.com 但是,无论我输入哪个URL,都会将
my domain.com
的所有文件存储在哪里。 我想在访问时查看
root/usr/share/nginx/index/html/prod/
的内容
prod.my-domain.com
但是,我需要根目录
/usr/share/nginx/index/html/

根目录
在位置
/
的两种服务器配置中都是相同的,这是您的错误吗?@AhmadSherif是的,我忘了在这里替换它,因为我一直在尝试各种方法,但都不起作用。无论如何,这解决了我的问题,我被迫为主站点和prod创建两个文件夹,作为
main.site.com
&
prod.site.com
,也许这个答案对新问题有帮助
server {
        listen 80;
        server_name prod.my-domain.com;

      location / {
         root /usr/share/nginx/html/;
         index index.php index.html index.htm;
       }
       location /prod{
            autoindex on;
       }

      error_page 404  /404.html;
            location  = /404.html {
            root /usr/share/nginx/index/html/prod/;
      }

     error_page 500 502 503 504 /50x.html;
          location = /50.html {
          root /usr/share/nginx/html;
     }

   location ~ \.php$ {
         fastcgi_intercept_errors on;
         error_page  404  /path/to/404.htm;
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include        fastcgi_params;
    }

}
 server{
    listen       80;
    server_name  my-domain.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index index.php  index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
       fastcgi_intercept_errors on;
       error_page  404  /path/to/404.htm;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }