Skip to content
On this page

MPA+nginx 路由分发

这种方式就是在多个独立的 SPA 应用之间跳转。

优点:

  • 框架无关
  • 独立开发、部署、运行
  • 应用之间 100% 隔离

缺点:

  • 应用之间的彻底割裂导致复用困难。
  • 每个独立的 SPA 应用加载时间较长,容易出现白屏,影响用户体验;
  • 后续如果要做同屏多应用,不便于扩展。
nginx
server {

    listen 80;

    server_name xxx.xxx.com;

    location / {
        index  index.html
        try_files $uri $uri/ /index.html;
    }

    location /client_studycenter {
        alias /code/studycenter;
        try_files $uri $uri/ @rewrites;
    }

    location @rewrites {
        rewrite ^/(client_studycenter)/(.*)$ /$1/index.html last;
    }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
沪ICP备20006251号-1