Forum Discussion

monica_74227's avatar
Icon for Nimbostratus rankNimbostratus
Oct 28, 2009

how to do HTTP header replace with iRule

Hey guys,


well, the client wants to use special string to replace the http response header's host string. could you help me to check the following iRule or correct it




set newhost ""


if { [HTTP::header host] eq "" } {


HTTP::header replace host $newhost }





2 Replies

  • There is no Host header in HTTP responses. What is the customer trying to achieve? Do they want to change the hostname displayed in the browser address bar? If so, you'd want to send the client an HTTP redirect instead of rewriting a header in the response. Other possibilities are:

    - The customer wants to rewrite a redirect in a 30x response.

    In that case you could use an iRule like this:

    - The customer wants to rewrite the host header in the request without the client seeing the change. In that case, you could use a very similar iRule to what you posted:

     when HTTP_REQUEST { 
        if { [HTTP::header host] eq "" } { 
           HTTP::header replace Host "" 

  • Hey Aaron,



    Thank you for your help! We have finished the iRule, as the following:



    when HTTP_RESPONSE {



    if { [HTTP::header is_redirect]} {



    HTTP::header replace Location [string map -nocase {} [HTTP::header value Location]]