irule not working as expected

Hi, i have a simple redirection irule which is not working . Here it is

when HTTP_REQUEST { if { [HTTP::host] equals “cmsint-qa.abc.com/public/header.html?SiteId=GCR”} { HTTP::redirect “https://gcr-qa.abc.com/public/header.html\[HTTP::uri]” } }

The redirected website opens just fine and DNS looks ok. Any ideas what i am doing wrong here?

HTTP::host is only the host, it doesn’t include the URI.

host: cmsint-qa.abc.com path: /public/header.html uri: /public/header.html?SiteId=GCR

you’ll want to split the conditions up so they’ll match. You can add the host condition in there as well, but without it, something like this should work:

when HTTP_REQUEST {
 if { [HTTP::uri] equals "/public/header.html?SiteId=GCR"} {
   HTTP::redirect "https://gcr-qa.abc.com/public/header.html[HTTP::uri]"
  }
}

e.g.

config

root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.20.15:80
    ip-protocol tcp
    mask 255.255.255.255
    pool foo
    profiles {
        http { }
        tcp { }
    }
    rules {
        myrule
    }
    source 0.0.0.0/0
    source-address-translation {
        type automap
    }
    vs-index 34
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule myrule
ltm rule myrule {
    when HTTP_REQUEST {
  if { [HTTP::host] equals "cmsint-qa.abc.com" and [HTTP::uri] equals "/public/header.html?SiteId=GCR" } {
    HTTP::redirect "https://gcr-qa.abc.com[HTTP::uri]"
  }
}
}

 test

[root@ve11a:Active:In Sync] config  curl -I http://172.28.20.15/public/header.html?SiteId=GCR -H "Host: cmsint-qa.abc.com"
HTTP/1.0 302 Found
Location: https://gcr-qa.abc.com/public/header.html?SiteId=GCR
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

Yes, that works. Thanks nitass :slight_smile: