Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
提供单个文件,而不考虑nginx中的位置匹配_Nginx - Fatal编程技术网

提供单个文件,而不考虑nginx中的位置匹配

提供单个文件,而不考虑nginx中的位置匹配,nginx,Nginx,我当前的配置是 server{ listen 80; server_name some.com; location /{ root /var/www; index index.html; } } 这和 /->/var/www/index.html /container->/var/www/container/index.html 我希望位置匹配不会附加到根。因此,匹配将是 /->/var/www/index.html /contai

我当前的配置是

server{
    listen 80;
    server_name some.com;

    location /{
       root /var/www;
       index index.html;
    }
}
这和

/
->
/var/www/index.html

/container
->
/var/www/container/index.html

我希望位置匹配不会附加到根。因此,匹配将是

/
->
/var/www/index.html

/container
->
/var/www/index.html


无论位置如何,它都是相同的,我将动态处理渲染。

通常的方法是使用
try\u files
提供默认URI:

server{
    listen 80;
    server_name some.com;

    root /var/www;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }
}
有关详细信息,请参阅