This is written in the configuration:
location / {
rewrite /bug.html /weather/index.html?mode=test last;
error_page 404 = @nodejs;
}
When the browser opens /bug.html
, the /weather/index.html page does appear, but the browser address bar does not change.
How is this going?
淡淡烟草味2017-05-16 17:22:33
Try changing it to this
location / {
rewrite /bug.html /weather/index.html?mode=test redirect;
error_page 404 = @nodejs;
}
There are many ways to rewrite, and the one you wrote actually means 用户访问老地址时,服务器到新地址去抓取内容然后展现
,看清楚了吗,你可以理解为服务器内部做了个跳转,而外部地址不会改变。如果你想让浏览器直接去访问新地址,请用redirect
.
巴扎黑2017-05-16 17:22:33
Single rewrite is a server redirection: nginx grabs another url and returns it to the current request
The kind you want is client redirection: nginx returns 301/302 to the current request, letting the browser request the new url by itself