Forum Discussion

Mike_Smith_1088's avatar
Mike_Smith_1088
Icon for Nimbostratus rankNimbostratus
Apr 01, 2014

I need to rewrite a URI between the F5 and Server only

I have a situation where I would like to remove a directory from the URI but keep all other information in tact.

 

example: Between the Client and F5 I need https://www.company.com/information/any_directory_name/any_pgm_name.aspx Between the F5 and Server I need https://www.company.com/any_directory_name/any_pgm_name.aspx

 

I do not want the client to know the "/information" directory is missing from the internal request/response. What do I need to do on the F5 to rewrite the URI for request and response? If this can be done easily within the GUI how would I config it?

 

This is not working.

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { {HTTP::uri string map { "/information" "" } } }}

 

4 Replies

  • Try this:

    when HTTP_REQUEST {   
        HTTP::uri [string map {"/information" ""} [HTTP::uri]]
    }
    

    The above will brute force remove any instance of "/information" in the client side request URI. It will not, however, insert the URI into responses. Not sure if that's necessary, so not touching on possible solutions here.

  • Thanks Kevin That definitely helped, but it is only half my issue. I do need to add the "/information" directory back to the beginning of the URI and send back to the client.

     

  • Will this work??

     

    when HTTP_REQUEST {

     

    set client_uri [HTTP::uri] set client_host [HTTP::host] HTTP::uri [string map {"/information" ""} [HTTP::uri]] } when HTTP_RESPONSE { HTTP::respond "http://$client_host$client_uri" }