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

6 Replies

  • Hi Chakkaravarthy,

     

    i guess noone could write you an Script without additional information of which type of an URL you're trying to change?

     

    Do you want to change a Request URL?

     

    Do you want to change a delivered Redirect URL?

     

    Do you want to perform a redirect from the old URL to the new URL?

     

    Do you want to change a Referer URL?

     

    Do you want to change a clickable link within some web content?

     

    Every mentioned scenario needs completely different actions. So I encourage you to write some additional information of what your current objective is...

     

    Cheers, Kai

     

  • hello kai

     

    thanks for your quick reply

     

    I want to change from old URL to new URL. hope this clarifies

     

  • Hi Chakkaravarthy,

     

    it doesn't clarify that much, since there is not "the one an only URL".

     

    An URL is per definition just a standarized language to specify a location. But in term of webtraffic it can be a "referer URL", a "request URL", a "redirect URL" or a "clickable link" within some content.

     

    Furthermore, the "i want to change" could be a "rewrite" or a "reroute" depending of the URL type.

     

    Cheers, Kai

     

  • Information is not sufficient. I guess you wanted to redirected from Old URL to New URL? As per details, it look like you have given back-end server hostname & port. Please write some more words.

     

  • If you want to perform a redirect (that is, respond to user-agent with a 302 and a Location header):

    when HTTP_REQUEST {
        if { [getfield [HTTP::host] : 1] eq "x1y1z1.xyzglobal.local" } {
            HTTP::redirect "http://x2y2z2.x2y2z2global.local:8080[HTTP::uri]"
        }
    }
    

    If you care to redirect only when the uri-path is "/":

    when HTTP_REQUEST {
        if { [HTTP::path] eq "/" and [getfield [HTTP::host] : 1] eq "x1y1z1.xyzglobal.local" } {
            HTTP::redirect "http://x2y2z2.x2y2z2global.local:8080[HTTP::uri]"
        }
    }
    

    This assumes that this iRule is attached to a Virtual Server listening on port 8080.

    If you want to transparently transform the Request-URI (that is, change it before sending it to the pool member, but retain original URL for user-agent):

    when HTTP_REQUEST {
        if { [getfield [HTTP::host] : 1] eq "x1y1z1.xyzglobal.local" } {
            HTTP::host "x2y2z2.x2y2z2global.local"
        }
    }
    

    Having said all of that, it actually looks like you want to perform a redirect such that if the request is for then the target is . If this is the case, then the trick is, of course, the extraction. Assuming that the pattern is strictly x1y1z1.xyzglobal.local (and x, y and z are exactly one digit each), then:

    when HTTP_REQUEST {
        if { [scan [getfield [HTTP::host] : 1] "%1d1%1d1%1d1.%3dglobal.local" a1 a2 a3 b] == 4 } {
            if { "$a1$a2$a3" eq $b } {
                HTTP::redirect "http://${a1}2${a2}2${a3}2.${a1}2${a2}2${a3}2global.local:8080[HTTP::uri]"
            }
        }
    }
    

    Again, if you want transparent rewriting, then you must use

    HTTP::host
    with the rewritten Host header.