nginx location设置多个web项目,如何访问二级路由下的子路由呢?

我期望访问 ab/cancelledProjectNum/页面,但是实际却访问到了 location /。现在能单独访问到/ab。也能访问到ab/下的静态资源,但是访问不到下面的子路由。
使用的react-route的路由配置
该如何写配置呢?

location ^~ /ab {
        alias /data/gdl_form/big/;
        index  index.html index.htm;
        try_files $uri $uri/ /big/index.html;
    }

    location / {
        root   /data/gdl_form/js;
        index  index.html index.htm;
        try_files   $uri $uri/ab /index.html;
    }
阅读 2.3k
1 个回答

不涉及到复杂的路径的话只要这样就可以了

location /ab/ {
    # 你自己的那些alias和try_files配置
}

location / {
    # 你自己的 root 配置
    try_files $uri /index.html; #uri/ab 去掉,不应该有
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题