Forum Discussion

mnb_63148's avatar
mnb_63148
Icon for Nimbostratus rankNimbostratus
Feb 10, 2014

Need assistance rewriting a hostname and appending a uri.

I am having trouble rewriting a hostname and appending a url.   Below is a sample of what I am trying to do:   The user is going to https://apples.com. I need to send the user to https://lemons...
  • James_Deucker_2's avatar
    Feb 10, 2014

    Your HTTP_RESPONSE is incorrect and unnecessary, it's trying to replace the HTTP header called lemons.com with lemons.com if a Host header existed in the response, or killing the TCP connection with a RST and causing a blank page if the Host header didn't exist in the response. Have a look in /var/log/ltm for TCL Errors to determine what's happening.

    Case insensitive:

    when HTTP_REQUEST {
        switch [string tolower [HTTP::uri]] {
            "/" -
            "/tree.html" {
                HTTP::uri "/fruit/TREE.html" 
            }
        }
        HTTP::header replace Host "lemons.com" 
    }
    

    Case sensitive:

    when HTTP_REQUEST {
        switch [HTTP::uri] {
            "/" -
            "/TREE.HTML" {
                HTTP::uri "/fruit/TREE.html" 
            }
        }
        HTTP::header replace Host "lemons.com" 
    }