Home  >  Q&A  >  body text

What is the difference between rewrite and redirect in nginx?

My popular understanding:

redirect是浏览器向服务端发起请求后,服务端响应码为301或者302之类的重定向状态码,然后浏览器再次访问重定向后的url,等于是有两次请求。rewrite是直接返回修改后的url对应的内容,浏览器也就只有发起一次请求。
这里的疑惑是,真实测试的时候发现,rewrite也会修改地址栏上的地址,这里如果按照我的逻辑不应该会修改地址栏的地址啊。。。
伊谢尔伦伊谢尔伦2714 days ago430

reply all(2)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-16 17:09:48

    That’s all I can think of at the moment

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:09:48

    You understood it correctly. If you don’t understand, take a look at the response header

    reply
    0
  • Cancelreply