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

Steve_Brown_882's avatar
Steve_Brown_882
Historic F5 Account
Mar 14, 2007

Newbie Question URI Rewrite

Hello All,

 

I am in need of some help with an irule to rewrite a uri and uri redirects. I have a url which is https://prepend-host.domain.com/whatever and I would like to rewrite this inbound to be https://host.domain.com/whatever dropping the prepend- from the url. I also need to add the prepend- back to the url on the outbound redirects. I think this should not be that hard to accomplish. I am already decrypting the ssl so I am crossing my fingers that a simple irule would do the trick. Thanks in advance!!!

2 Replies

  • Steve_Brown_882's avatar
    Steve_Brown_882
    Historic F5 Account
    Ok so I have dug a bit and gotten myself started. I have a dirty verion of the first half of my requirment. This appears to be working the way I want although I need to make it more generic so I can use it for multiple sub domains. What I am looking for now is help writting the other half of this. Which would add the begin- portion back to the responces.

     

     

     

    when HTTP_REQUEST {

     

    if {[HTTP::host] contains "begin-sub."} {

     

    HTTP::header replace "Host" "sub.host.com"

     

    log local0. "This is the new host: [HTTP::header "Host"]"

     

    }

     

    }
  • Steve_Brown_882's avatar
    Steve_Brown_882
    Historic F5 Account
    Actually I have this working in a very dirty mannor with these two rules and a stream profile. However I could use some help with cleanning these up so that I am not replacing with hardcoded data.

     

     

    when HTTP_REQUEST {

     

    if {[HTTP::host] contains "prefix-"} {

     

    HTTP::header replace "Host" "subhost.host.com"

     

    log local0. "This is the new host: [HTTP::header "Host"]"

     

    }

     

    }

     

     

     

    when HTTP_RESPONSE {

     

    if {[HTTP::header "Location" ] starts_with "https://subhost."} {

     

    HTTP::header replace "Location" "https://prefix-subhost.host.com/etc.asp"

     

    log local0. "This is the new outbound host: [HTTP::header "Host"]"

     

    }

     

    }