I need to rewrite a portion of a query string while preserving all other components, how can I do this?

Update iRule to change id to entityId for the search results redirect only: Old: http://search.net/Pages/results.aspx?k=SLEEVE&entity=compounds&id=NXP-AFB113 New: http://search.net/Pages/results.aspx?k=SLEEVE&entity=compounds&entityid=NXP-AFB113

I need to change the &id= to &entityid=

e.g.

config

root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.24.10:80
    ip-protocol tcp
    mask 255.255.255.255
    pool foo
    profiles {
        http { }
        tcp { }
    }
    rules {
        qux
    }
    source 0.0.0.0/0
    source-address-translation {
        type automap
    }
    vs-index 13
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo
ltm pool foo {
    members {
        200.200.200.101:80 {
            address 200.200.200.101
        }
    }
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
    when HTTP_REQUEST {
  set qry [HTTP::query]
  set id [URI::query "?$qry" "id"]
  if { $id ne "" } {
    HTTP::query [string map [list id=$id entityid=$id] $qry]
  }
}
}

 trace

[root@ve11a:Active:In Sync] config  ssldump -Aed -nni 0.0 port 80
New TCP connection 1: 172.28.24.1(40420) <-> 172.28.24.10(80)
1416182539.2412 (0.0025)  C>S
---------------------------------------------------------------
GET /Pages/results.aspx?k=SLEEVE&entity=compounds&id=NXP-AFB113 HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: 172.28.24.10
Accept: */*

---------------------------------------------------------------

New TCP connection 2: 200.200.200.14(40420) <-> 200.200.200.101(80)
1416182539.2430 (0.0017)  C>S
---------------------------------------------------------------
GET /Pages/results.aspx?k=SLEEVE&entity=compounds&entityid=NXP-AFB113 HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: 172.28.24.10
Accept: */*

---------------------------------------------------------------

e.g.

config

root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.24.10:80
    ip-protocol tcp
    mask 255.255.255.255
    pool foo
    profiles {
        http { }
        tcp { }
    }
    rules {
        qux
    }
    source 0.0.0.0/0
    source-address-translation {
        type automap
    }
    vs-index 13
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo
ltm pool foo {
    members {
        200.200.200.101:80 {
            address 200.200.200.101
        }
    }
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
    when HTTP_REQUEST {
  set qry [HTTP::query]
  set id [URI::query "?$qry" "id"]
  if { $id ne "" } {
    HTTP::query [string map [list id=$id entityid=$id] $qry]
  }
}
}

 trace

[root@ve11a:Active:In Sync] config  ssldump -Aed -nni 0.0 port 80
New TCP connection 1: 172.28.24.1(40420) <-> 172.28.24.10(80)
1416182539.2412 (0.0025)  C>S
---------------------------------------------------------------
GET /Pages/results.aspx?k=SLEEVE&entity=compounds&id=NXP-AFB113 HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: 172.28.24.10
Accept: */*

---------------------------------------------------------------

New TCP connection 2: 200.200.200.14(40420) <-> 200.200.200.101(80)
1416182539.2430 (0.0017)  C>S
---------------------------------------------------------------
GET /Pages/results.aspx?k=SLEEVE&entity=compounds&entityid=NXP-AFB113 HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: 172.28.24.10
Accept: */*

---------------------------------------------------------------

HTTP::query Returns (or sets in v11.5+) the query part of the HTTP request. HTTP::query F5 Cloud Docs

HTTP::query Returns (or sets in v11.5+) the query part of the HTTP request. HTTP::query F5 Cloud Docs