Redirect from Context

The Redirect method sends a redirect response to the client of an absolute or relative target URL. It accepts 2 input arguments, a string and an optional integer. The first parameter is the target url to redirect. The second one is the HTTP status code should be sent among redirection response, If the second parameter is missing, then it defaults to 302 (StatusFound). It can be set to 301 (Permant redirect), StatusTemporaryRedirect(307) or 303 (StatusSeeOther) if POST method.

Redirect(urlToRedirect string, statusHeader


Redirect from /home to /.

package main
import ""
func main() {
app := iris.New()
app.Get("/", index)
app.Get("/home", home)
func index(ctx iris.Context) {
ctx.Writef("Hello, %s!", "World")
func home(ctx iris.Context) {
ctx.Redirect("/home", iris.StatusPermanentRedirect)