晨风

-------------------- 业精于勤,荒于嬉;行成于思,毁于随

导航

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

Posted on 2020-04-16 12:50  shenyixin  阅读(9287)  评论(0)    收藏  举报

配置多个站点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;
    }

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

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