nginx重定向路径 rewrite重新编辑html页面名称
修改前:http://localhost:80/views/home.html?pageNo=2&pageSize=10
修改后:http://localhost:80/views/home_2.html
nginx配置:
location /views/ {
root C:/files;
#如果pageNo参数有值
if ($arg_pageNo) {
#将URL中的第一个参数($arg_pageNo)的值添加到URL中并用下划线分隔,
#将新的URL作为重定向目标。
rewrite ^/(.*).html$ /$1_$arg_pageNo.html break;
}
try_files $uri @tomcat_static;
}
location @tomcat_static {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080;#跳转tomcat或跳转固定地址都可
}