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

djkromarek's avatar
djkromarek
Icon for Nimbostratus rankNimbostratus
Jun 24, 2013

removing part of uri in redirect

We are moving servers and our paths from site to application are changing. For example, I have a current path of testsite.com/applications/testapp/lowerfolder/lowerfolder/test.aspx?param1=1&param2=2

 

 

I need to have it redirect to testsite.com/testapp/lowerfolder/lowerfolder/test.aspx?param1=1&param2=2

 

The parameters and the pages could change along with the two lowerfolders. All I need to do is remove the /applications from the path. Could anyone help with this?

 

 

I have BIG-IP version 11.1

 

 

Thanks,

 

Deni

 

16 Replies

  • Using Kevin's rule, I put in the logging and it looked like everything that was under the host testsite.com and within the applications part (not just testapp) went through this rule and logged that it tried to send it to testsite.com/applications/testapp/.... This was every application within the /applications folder not just /testapp. I've had to remove the rule since it seems to want to route everything to the same page. I do not want every application within /applications to go to the redirect, only the application called /testapp. Is there some explanation as to why every application tries to follow the redirect?
  • I do not want every application within /applications to go to the redirect, only the application called /testapp

    I don't think I got that from your original request. Try this:

    
    when HTTP_REQUEST {
         log local0. "incoming URI: [HTTP::uri]"
         if { [HTTP::host] contains "testsite.com" } {
              if { [string tolower [HTTP::uri]] starts_with "/applications/testapp/" } {
                   set newpath [HTTP::host][string map {"/applications/testapp/" "/testapp/"} [HTTP::uri]]
                   log local0. "redirecting to https://$newpath"
                   HTTP::redirect "https://$newpath"
              }
         }
    } 
    

  • At this time, we do not have a test F5, so I am having to apply this on a production F5. I wont be able to apply this rule to test until after work hours. I'll let you know the results in here.

     

     

  • It is still redirecting to /applications/testapp. Although now it seems to be only redirecting the testapp, but still going to the /applications folder. It gives an error that The page isn't redirecting properly it still gives the message that ' Firefox has detected that the server is redirecting the request for this address in a way that will never complete.' I need to check out the other iRules that may be affecting this application. But it doesn't seem to be dropping the /applications part of the URI.

     

     

     

  • Below is the iRule that worked. when HTTP_REQUEST { if { [HTTP::host] contains "testsite.com" } { if {[string tolower [HTTP::uri]] starts_with "/applications/testapp/" } { set URI [substr [HTTP::uri] 14] HTTP::redirect "http://[HTTP::host]/$URI" } } }