Jump to content
Toggle menu
  • 51 articles
  • 24 files
  • 4 users
  • 750 edits
Tech-Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Redirect - Custom 404

From Tech-Wiki


Technical reference for Redirect - Custom 404.

Reference

when HTTP_RESPONSE {

    if { [HTTP::status] == "403" } {
        HTTP::respond 404 content "404 File Not Found" Mime-Type "text/html"
    }
    elseif { [HTTP::status] == "404" } {
        HTTP::redirect "http://www.customerrorpage.com"
    }
}

Or below

when HTTP_REQUEST {
  set host [HTTP::host]
  set path [HTTP::path]
}
when HTTP_RESPONSE {
  if { [HTTP::status] eq "404" } { HTTP::redirect "https://${host}/my404page?url=${path}" }
}

You CAN'T use host/uri under RESPONSE, like below:

when HTTP_REQUEST {
 #Redirects all to HTTPS keeps URI intact
 HTTP::redirect https://[HTTP::host][HTTP::uri]
}

See also