Forum: NGINX Preferred way to do redirects (rewrite or return)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2974d09ac2541e892966b762aad84943?d=identicon&s=25 justin (Guest)
on 2013-09-23 22:39
(Received via mailing list)
What is the preferred way to do redirects? I know of two solutions:

rewrite "^/help/?$" https://support.mydomain.com permanent;

or

location ^/help/?$ {
  return 301 https://support.mydomain.com;
}

I think I like using a location block and a return statement. Which is
faster though and the standard?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,243075,243075#msg-243075
40b4c848b8fcd63b0cb60b9d170c3a77?d=identicon&s=25 Valentin V. Bartenev (Guest)
on 2013-09-23 22:46
(Received via mailing list)
On Tuesday 24 September 2013 00:38:53 justin wrote:
> I think I like using a location block and a return statement. Which is
> faster though and the standard?
>

Faster:

  location =/help { return 301 https://support.mydomain.com; }
  location =/help/ { return 301 https://support.mydomain.com; }


 wbr, Valentin V. Bartenev
This topic is locked and can not be replied to.