1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# 重写 - 不适用于相对路径资源引用 # 重定向 - 适用于相对路径资源引用 # 主应用重写,子应用重写 # 受限于 nginx 的内部重定向次数 server { index index.html; location / { add_header Cache-Control "no-cache, no-store"; try_files $uri $uri/index.html @rewrite; } location @rewrite { rewrite ^(.+)/([^/]*) $1 last; rewrite ^/([^/]*) / last; } } # 主应用重定向,子应用重定向 # 受限于 nginx 的内部重定向次数 server { index index.html; location / { add_header Cache-Control "no-cache, no-store"; try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^(.+)/([^/]*) $1 last; rewrite ^/([^/]*) /index.html permanent; } } # 主应用重定向,子应用重定向 # 受限于浏览器的 301 重定向次数 server { index index.html; location / { add_header Cache-Control "no-cache, no-store"; try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^(.+)/([^/]*) $1 permanent; rewrite ^/([^/]*) /index.html permanent; } } # 主应用重写,子应用重定向 # 受限于 nginx 的内部重定向次数 server { index index.html; location / { add_header Cache-Control "no-cache, no-store"; try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^(.+)/([^/]*) $1 last; rewrite ^/([^/]*) / last; } } # 主应用(不完全)重定向,子应用重定向 # 受限于浏览器的 301 重定向次数 server { index index.html; location / { add_header Cache-Control "no-cache, no-store"; try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^(.+)/([^/]*) $1 permanent; rewrite ^/([^/]*) / last; # rewrite ^/([^/]*) /index.html last; } } |