powered by
Creates an HTTP handler that returns a redirect response.
handler_redirect(path, location, status = 302L, prefix = FALSE)
A handler object for use with http_server().
http_server()
URI path to match (e.g., "/old-page").
URL to redirect to. Can be relative (e.g., "/new-page") or absolute (e.g., "https://example.com/page").
HTTP redirect status code. Must be one of:
301 - Moved Permanently
302 - Found (default)
303 - See Other
307 - Temporary Redirect
308 - Permanent Redirect
[default FALSE] Logical, if TRUE matches path as a prefix.
# Permanent redirect h1 <- handler_redirect("/old", "/new", status = 301L) # Redirect bare path to trailing slash h2 <- handler_redirect("/app", "/app/")
Run the code above in your browser using DataLab