我想配置nginx的不同位置在/上,我有以下配置。如何为不同路径配置nginx
server {
listen 80;
server_name bla.com;
location =/{ // on exact route match such as 'bla.com'
root /usr/share/nginx/html/folder; // it has index.html
}
location/{ // rest all url such as bla.com/* are captured here eg. bla.com/temp/12
root /usr/share/nginx/html/dist; // different folder
}
}
我该怎么做?
我也尝试了以下配置,没有运气 -
server {
listen 80;
server_name bla.com;
root /usr/share/nginx/html;
location =/{
try_files $uri /folder/index.html; // it has index.html
}
location/{ // rest all url such as bla.com/* are captured here eg. bla.com/temp/12
try_files $uri /dist/index.html; // different folder
}
}
我真的不知道你在'/'上的不同位置是什么意思。你的意思是说你的域名根目录有两个不同的网站?因为我认为这是不可能的(至少在NGINX配置文件中是不可能的)。 – StackerStan
我的意思是,如果我给bla.com我想要去一个位置和bla.com/temp到其他位置 –