Forum Discussion

C_D_18583's avatar
C_D_18583
Icon for Nimbostratus rankNimbostratus
May 07, 2008

How to modify the PATH of the URI

How do I modify the path of the URI ?

 

 

(EG)

 

 

from: domainname/path/to/my/service

 

to domainname/myservice

 

 

I want to be able to strip /path/to/my but the number of "/'s" is not known or fixed.

 

 

Thanks in Advance

 

 

4 Replies

  • You can use HTTP::path (Click here) to retrieve or set the path. The host and query string, if present, aren't modified.

     

     

    Aaron

     

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    If you're looking to take whatever URI comes in, assuming it has a certain service name on the end, and update the URI with the one above, you'd want something like:

     
     when HTTP_REQUEST { 
       switch -glob [string tolower [HTTP::uri] { 
         "*service" { 
           HTTP::uri "/myservice" 
         } 
       } 
     } 
     

    If there are only certain URIs you want to replace, you can set those up in the switch as well.

    Colin
  • Yes . I am looking to take the URI that comes in and strip the path to the service name . I do have a number of service names . Would I have to add each one of these names to the rule ?

     

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Yes, if you want to check to see if it's one of, say, 10 different URIs and change them accordingly, then you're going to have to add multiple switch cases to check for those. You could also use the matchclass command, if it's easier for you to modify a class in the long run, but that depends largely on how often you'll be modifying these once the rule is in place.

     

     

    Colin