Nginx一个server配置多个location 404问题解决

2850阅读 0评论2020-12-10 wwm
分类:LINUX

配置多个站点404
我选择了配置多个location。

location / {
         root   /data/html/;
         index  index.html index.html;
    }
    location /publicity {
         root /usr/local/nginx/hzcloud-timp-front/;
         index  index.html index.htm;
    }

配置完以后访问。 提示404
找了好久才搞明白, location如果一个特定的url 要使用别名,不能用root,alias指定的目录是准确的,root是指定目录的上级目录,改动后即可以使用了

location /publicity {
         alias /usr/local/nginx/hzcloud-timp-front/;
         index  index.html index.htm;
    }
 
又比如
 location ^~/doc/ {
        index  index.html index.htm;
        alias  /usr/share/nginx/html/apidoc/;
        #或者用下面
 # root  /usr/share/nginx/html;  

 }

上一篇:python快速简单启动一个web
下一篇:nginx location 中的 alias 和 root(转载)