Forum Discussion

Ajmal_2608's avatar
Ajmal_2608
Icon for Nimbostratus rankNimbostratus
Mar 14, 2014

Need a specific character to be changed in the URI

Hi

 

I am looking for an iRule/regex/string handling mechanism which can help me with this:

 

incoming - www.website.com/global/customers/siteA convert to - www.website.com/global/Customers/siteA (only nee the character c to go C)

 

I have almost 1000 sites like this and need something that can incorporate all of them HTTP:host will keep changing and the site name is also variable for customer to customer

 

If this would have been 1 site then I can probably write a hardcoded value but they are more than 1000

 

Please advise

 

2 Replies

  • Try this one (remove the logging before applying it in production):

    when HTTP_REQUEST { 
    
        set uri [HTTP::uri]
    
        log local0. "Uri before replacing: $uri"
    
        if { $uri starts_with "/global/customers/" } {
    
            Replacing uri
            set uri [string map {"/global/customers/" "/global/Customers/"} $uri]]
    
            log local0. "Uri after replacing: $uri"
            HTTP::uri $uri
    
        }
    }
    

    Good luck!

    /Patrik