Forum Discussion

Iggy_E's avatar
Iggy_E
Icon for Nimbostratus rankNimbostratus
May 25, 2021

Redirecting to a maintenance page based on http response code and content-type == text/html

We currently redirect to "maintenance pages" based on HTML response error codes I.E http 500 error. We will like to add also checking for response on content type "content-type == text/html" and not redirect if the content type is json.

We have something very simple in place on a few i-Rules:

when HTTP_RESPONSE {
  if { [HTTP::status] contains "500"} {
    HTTP::redirect "https://www.abcdefg.error.com/error.html"
  }
}

How do we craft this new i-Rule?

2 Replies

  • Try something like this:

    if { [HTTP::status] contains "500" and [HTTP::header exists "content-type"] } {
      if { [string tolower [HTTP::header value "content-type"]] equals "text/html" }
        { # redirect here
        }
    }
    • Iggy_E's avatar
      Iggy_E
      Icon for Nimbostratus rankNimbostratus

      Thanks, I'll try this and let you know.