In terms of browser / end user
redirect_to "http://www.domain.com" redirect_to "http://www.domain.com", :status => 302 redirect_to "http://www.domain.com", :status => 301
are equivalent
head 301, :location => "http://www.domain.com/" head 302, :location => "http://www.domain.com/"
There are some minor technical differences that may lead to one option and not another.
redirect_to exists as part of the routing architecture. You can pass URL parameters, and the method automatically creates the final location in accordance with the applicationโs routing rules.
redirect_to root_url, :status => 302 redirect_to { :controller => "main", :action => "index" }, :status => 302
In contrast, head is a lower-level API for working with response headers. It doesnโt care about the meaning of the headers you provide in response. This is useful when you need to work with headers. I would not use it to configure redirection.
source share