Forum Discussion

Dan_Brown_19294's avatar
Icon for Nimbostratus rankNimbostratus
Mar 12, 2012


Hi all,



Just attempting to update an HTTP_RESPONSE iRule to include a HTTP:host as well as it currently covers too much of the pool it is applied to.




According to I can use HTTP::host and according to I can use it against HTTP_RESPONSE.




When I try and implement it though I get an error stating:


[command is not valid in current event context (HTTP_RESPONSE)] [HTTP::host]






if { ( [HTTP::host] equals "" ) and ( [HTTP::status] == 404 ) } {


HTTP::redirect ""








The reason I am checking the host is multiple host headers are on the same virtual server and I only want to apply this redirect to 404s on the one host.




Is the wiki wrong or is it my implementation?




Many thanks,





3 Replies

  • Hi Dan,

    looking into the standard, Host seems to be a request header only, see , e.g. p127 14.23

    so this makes sense. Will double-check with a colleague, and then update the wiki

    However, use the following to achieve your goal:

    when HTTP_REQUEST {
        set my_host_header [HTTP::host]
    when HTTP_RESPONSE {
        if { ( $my_host_header equals "" ) and ( [HTTP::status] == 404 ) } {
            HTTP::redirect ""


  • I updated the HTTP::host wiki page to remove the response events. Thanks for pointing this error out.