chickadee » awful » redirect-to

redirect-to uriprocedure

Perform an HTTP redirection (code 302) to the given uri (either a string or a uri-common URI object). To be used from define-page handler. Example:

(use awful)

;; / -> /foo
(define-page "/"
  (lambda ()
    (redirect-to "/foo")))

(define-page "/foo"
  (lambda ()
    "foo"))

The example above shows a redirection from / to /foo. Redirections can also be performed when the origin path is a regular expression:

(use awful)

;; /bar.* -> /foo
(define-page (regexp "/bar.*")
  (lambda (_)
    (redirect-to "/foo")))

(define-page "/foo"
  (lambda ()
    "foo"))