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

TNY_122436's avatar
TNY_122436
Icon for Nimbostratus rankNimbostratus
Dec 31, 2013

Rewrite certain URI content

Hello,

 

I have an existing iRule to rewrite a URI so it rewrites to something. I need to rewrite/omit a certain syntax and leave all else the same. For an example:

 

The existing iRule is to drop out '/Today' and rewrite it https://mycompany.com/Firstpage/Today/Monday/main -> should rewrite to https://mycompany.com/Firstpage/Monday/main

 

What I'm looking for is to still have the same effect, but if the client enters anything after /main/1/2/3 it should rewrite it as: /Firstpage/Monday/main/1/2/3. The problem is that there are so many variance after /main that the client can type in. We want the rewrite to include whatever the client types in after /main. How can I add to this existing iRule to make something like that work?

 

Here is my current iRule:

 

Code
   when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/Firstpage/Today/Monday/main"} { 
        HTTP::uri "/Firstpage/Monday/main" 

1 Reply

  • So is it a specific word, like "Today" that you need to remove, or a specific part of the URI, like the second field in the path?

    If the former, then a string map would probably work.

    when HTTP_REQUEST {
        if { [string tolower [HTTP::URI]] contains "/today" } {
            set URI [string map -nocase {"/today" ""} [HTTP::uri]]
        }
    }