【发布时间】:2023-03-18 00:58:01
【问题描述】:
我有两个 react 应用程序,一个在“/home/user/www”,一个在“/home/user/builds/checkout”。我想要任何以“/ checkout”开头的网址,例如。 '/checkout/complete'、'/checkout/error' 以使用该应用程序。我的 Nginx 配置文件中有以下设置:
root /home/user/www;
index index.html index.htm;
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.html break;
}
}
location ~ ^/checkout?(.*)$ {
allow all;
root /home/user/builds;
if (!-e $request_filename){
rewrite ^(.*)$ /index.html break;
}
try_files $uri $uri/index.html =404;
}
location ~ ^.+\..+$ {
try_files $uri =404;
}
转到 url '/checkout' 工作正常,但任何其他以 '/checkout' 开头的 url,如 '/checkout/complete' 和 'checkout/error' 都只是返回 404 页面。
【问题讨论】:
标签: nginx nginx-config nginx-location