簡體   English   中英

nginx如何重寫位置

[英]nginx how can I rewrite a location

我想要http:// localhost / health- > http://localhost/health.html ,如何編寫位置配置?

這是我的位置,但是不起作用。

location ^~  /health {
    root   /usr/share/nginx/html;
    index  health.html ;
}

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
}

謝謝你的幫助。

使用rewrite指令。

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;

    rewrite ^/heath/?$ /health.html? break;
}

來源: http : //nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM