Forum Discussion

Puli's avatar
Puli
Icon for Nimbostratus rankNimbostratus
May 20, 2010

iRule to remove string in header and the performance impact of it

We are planning to rewrite some url paths.

 

 

Below are two things we are planning.

 

 

1. www.abc.com/foo need to go to www.abc.com/us/foo

 

 

We can do this by adding "/us to the [http:uri]

 

And know is fine

 

 

2. www.abc.com/us/foo needs to be rewritten to www.abc.com/foo

 

 

How can i match the /us/ in the beginning ONLY and remove it as shown above?

 

 

For a site that get a peak of 100 hits/second, does this degrade performance of the site? since BigIP will look at every single hit and re-write.

 

 

Appreciate any suggestions.

 

thanks.

2 Replies

  • For 2 you could try something like this if you are wanting to use string map:

    
    when HTTP_REQUEST {
    if {[string tolower [HTTP::path]] starts_with "/us/foo"}{
    HTTP::redirect "http://www.abc.com[string map -nocase {/us/foo /us} [HTTP::uri]]"
    }
    }
    

    If you are just looking to redirect traffic going from www.abc.com/us/foo over to www.abc.com/foo then you could use a simple switch redirect like this:

     
    when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::uri] ] {
    "/us/foo*" {
    HTTP::redirect "http://www.abc.com/foo"
    }
    }
    }
    
  • I forgot to mention, if you use the switch command then the impact will be very minimal. I do not know the impact of using the string map, but I have used it on sites getting 100's of requests a minute and haven't noticed any kind of negative impact on the BIG-IP box or in using that site from a clients perspective.