Forum Discussion

sunnyman67_1367's avatar
Icon for Nimbostratus rankNimbostratus
Nov 03, 2013

URL rewrite through iRule

Hi Guys, i have one "Performance (HTTP)" virtual server on F5-1600 series, and i want to change the URL "" to "". i have tried all below scripts :


1- when HTTP_REQUEST { if {([string tolower [HTTP::host]] equals "")}{ HTTP::header replace Host "" } }


2- when HTTP_REQUEST { if { not ([HTTP::uri] starts_with "/xyz") } { HTTP::uri /xyz[HTTP::uri] } }


3- when HTTP_REQUEST { if {[HTTP::uri] equals {}} {HTTP::uri {} } }


but i wasn't successful! can anyone help me how can i do this through iRule ?


  • Hi Sunnyman,

    This will work;

    if { [IP::addr [IP::client_addr] equals] || [IP::addr [IP::client_addr] equals} { 
        SNAT with
        snatpool VM_SNAT_POOL_1_1_1_100
    } elseif { [IP::addr [IP::client_addr] equals] || [IP::addr [IP::client_addr] equals} { 
        SNAT with
        snatpool VM_SNAT_POOL_1_1_1_200

    But that's not a very scalable way of doing it if your list is going to grow. If it's going to grow then use an address datagroup, with values snatpool names, which you can use like this

    snatpool [class match -value [IP::remote_addr] equals dg_sunnyman_snatpools]

    or more correctly;

    set snatpool [class match -value [IP::remote_addr] equals dg_sunnyman_snatpools]
    if {$snatpool ne "") {
        snatpool $snatpool

27 Replies