Forum Discussion
- Brad_ParkerCirrus
I haven't tested this yet, but you could try somthing like this.
when HTTP_REQUEST { if {[string tolower [URI::path [HTTP::path] 2 2]] matches_regex "[a-z]{1,}"}{ HTTP::path "/[URI::path [HTTP::path] 3]" if {not ([HTTP::query] equals "")}{ HTTP::query "[HTTP::query]&id=[URI::path [HTTP::path] 2 2]" } else { HTTP::query "id=[URI::path [HTTP::path] 2 2]" } } }
- nitassEmployee
e.g.
irule [root@ve11c:Active:In Sync] config tmsh list ltm rule qux ltm rule qux { when HTTP_REQUEST { set uri [HTTP::uri] if { [scan $uri {/%*[^/]/%[^/]%s} id rest] == 2 } { set rest [string trimright $rest "?"] if { $rest contains "?" } { set newuri "${rest}&id=${id}" } else { set newuri "${rest}?id=${id}" } HTTP::uri $newuri } } when HTTP_REQUEST priority 1000 { log local0. "$uri > [HTTP::uri]" } } test [root@ve11c:Active:In Sync] config tail -f /var/log/ltm Apr 24 22:50:02 ve11c info tmm1[5649]: Rule /Common/qux : /prefix/foo/ > /?id=foo Apr 24 22:50:10 ve11c info tmm[5649]: Rule /Common/qux : /prefix/foo/path > /path?id=foo Apr 24 22:50:16 ve11c info tmm1[5649]: Rule /Common/qux : /prefix/foo/path? > /path?id=foo Apr 24 22:50:22 ve11c info tmm[5649]: Rule /Common/qux : /prefix/foo/path?p=7 > /path?p=7&id=foo