Forum Discussion

5 Replies

  • Here is what I have so far.

     

     

    when HTTP_REQUEST{

     

    if {[HTTP::host] contains "test" }{

     

    HTTP::uri "/sc/pol"

     

    }

     

    }

     

     

     

     

     

  • Steve_Brown_882's avatar
    Steve_Brown_882
    Historic F5 Account
    Here is a down and dirty way to do what you are looking for,

     

     

    when HTTP_REQUEST {

     

    HTTP::path [HTTP::path]/sc/pol

     

    }
  • Steve_Brown_882's avatar
    Steve_Brown_882
    Historic F5 Account
    Opps didn't see your second post...I would do this if you might have a query string that needs to stay.

     

     

    when HTTP_REQUEST{

     

    if {[HTTP::host] contains "test" }{

     

    HTTP::path "[HTTP::path]/sc/pol"

     

    }

     

    }

     

     

    or

     

     

    when HTTP_REQUEST{

     

    if {[HTTP::host] contains "test" }{

     

    HTTP::uri "[HTTP::uri]/sc/pol"

     

    }

     

    }
  • Nice one stjbrown. You could add a sanity check that the path doesn't already have the string as well.

    Joshua, do you want to append /sc/pol to the HTTP path (/path/to/file.ext) or the URI (/path/to/file.ext?param1=value1&param2=value2)?

    Here is an example of the first option:

    
    when HTTP_REQUEST{
       if {[HTTP::host] contains "test" and not ([HTTP::path] ends_with "/sc/pol") }{
    
           Due to a bug in v10.0 - 10.2.1, HTTP::path truncates the HTTP query string if present.
           This is described in CR142756. This should be fixed in 10.2.1HF1.
    
           Check if there is a query string
          if {[HTTP::query] eq ""}{
    
              No query string, so append the string to the path
             HTTP::uri "[HTTP::uri]/sc/pol"
    
          } else {
    
              Append the string to the path and re-append the query string
             HTTP::uri "[HTTP::path]/sc/pol?[HTTP::query]"
          }
       }
    }
    

    And an example of the second option:

    
    when HTTP_REQUEST{
       if {[HTTP::host] contains "test" and not ([HTTP::uri] ends_with "/sc/pol") }{
          HTTP::uri "[HTTP::uri]/sc/pol"
       }
    }
    

    Aaron