我有兩個反應應用程式,一個在“/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 頁面。
uj5u.com熱心網友回復:
您的配置看起來太復雜了。你可以試試這個嗎?
root /home/user/www;
index index.html index.htm;
location / {
try_files $uri /index.html;
}
location /checkout/ {
root /home/user/builds;
try_files $uri $uri/ /checkout/index.html;
}
如果/checkoutURI 不會將您重定向到/checkout/,請添加:
location = /checkout {
return 301 /checkout/;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/420965.html
標籤:
