Redirect

Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code.

If not specified, status defaults to 302 Found.
  1. func (c *Ctx) Redirect(location string, status ...int) error
  1. app.Get("/coffee", func(c *fiber.Ctx) error {
  2. c.Redirect("/teapot")
  3. })
  4. app.Get("/teapot", func(c *fiber.Ctx) error {
  5. c.Status(fiber.StatusTeapot).Send("🍵 short and stout 🍵")
  6. })
  1. app.Get("/", func(c *fiber.Ctx) error {
  2. return c.Redirect("/foo/bar")
  3. return c.Redirect("../login")
  4. return c.Redirect("http://example.com")
  5. return c.Redirect("http://example.com", 301)
  6. })