For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

therob152's avatar
therob152
Icon for Nimbostratus rankNimbostratus
Nov 11, 2016

Move [HTTP::host] field to path

Hi,

 

I am trying to do the following:

 

Inbound to F5 - https://customer.f5.com/ Re-write to - https://f5.com/customer

 

Where "customer" could be any potential customer.

 

I have started the rule like this:

 

when HTTP_REQUEST { set customer [getfield [HTTP::host] "." 1] if { [HTTP::host] contains $customer } { }

 

Then became a bit stuck. As I essentially need to remove the field, and then add it as a path.

 

I'm guessing as well that there might be more to the path than just that, more paths etc, so might essentially need to wildcard the end.

 

Many thanks for any help.

 

2 Replies

  • Hi Therob152,

    try the iRule below...

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] ends_with ".f5.com" } then {
            HTTP::uri "/[getfield [HTTP::host] "." 1][HTTP::uri]"
            HTTP::host [domain [HTTP::host] 2]  
        }
        log local0.debug "New URL is: https://[HTTP::host][HTTP::uri]"
    }
    

    Cheers, Kai

  • How about something like this to start with:

    when HTTP_REQUEST {
        set hlq [getfield [HTTP::host] ".f5.com" 1]
        HTTP::path "/$hlq[HTTP::path]"
        HTTP::host "f5.com"
    }
    

    You can wrap whatever conditional logic you need around it.