Redirect to a page or site
Redirect from a hash page with docly.redirect(url) - and how to make a redirect site.
docly.redirect(url)
#docly.redirect("https://www.google.com")# docly.redirect answers 302 Found - a temporary redirect - and takes one argument only. A second argument, such as docly.redirect(url, 301), does not redirect: it returns null and the page renders as if it was not called. For a page that has moved for good, put a .old file at the old path instead; it answers 301. See Redirect a moved page with a hash file.
Create a redirect site
Follow this example to redirect requests (with or without www) www.domain.com to domain.com. Or other domain.
Create a site and make ONLY a "#/404.hash" handler that catches all requests and redirects them to the other site:
>
#/404.hash
#{
docly.redirect("https://other-domain.com" + request.url);
}# Note that request.url always starts with / and holds the path from the published site root. The redirect is a 302 (temporary).