下面那个root换成alias就行了,因为location会拼接到root路径的后面,而alias不会。比如你的配置是:location /dir { root /usr/share/nginx; }则实际上访问/dir/的时候,nginx会在/usr/share/nginx/dir/下查找资源,而改为:location /dir/ { alias /usr/share/nginx; }则访问/dir/的时候,会在/usr/share/nginx/目录下查找资源。如果你期望原来的配置能工作,那么应该把你的xxxxx.html文件放到html/xxxxx/目录下才可以
下面那个
root
换成alias
就行了,因为location
会拼接到root
路径的后面,而alias
不会。比如你的配置是:
则实际上访问
/dir/
的时候,nginx会在/usr/share/nginx/dir/
下查找资源,而改为:则访问
/dir/
的时候,会在/usr/share/nginx/
目录下查找资源。如果你期望原来的配置能工作,那么应该把你的
xxxxx.html
文件放到html/xxxxx/
目录下才可以