[英]nginx how can I rewrite a location
I want http://localhost/health -> http://localhost/health.html , how can I write my location config? 我想要http:// localhost / health- > http://localhost/health.html ,如何编写位置配置?
this is my location ,but It does not work. 这是我的位置,但是不起作用。
location ^~ /health {
root /usr/share/nginx/html;
index health.html ;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
Thanks for your help. 谢谢你的帮助。
Use the rewrite
directive. 使用
rewrite
指令。
location / {
root /usr/share/nginx/html;
index index.html index.htm;
rewrite ^/heath/?$ /health.html? break;
}
Source: http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite 来源: http : //nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.