So it's always the last subdirectory that you want to parse? And are the digits always on their own // or // or following a hyphen like this /AAA-AAA-AAA-/ or /AAA-AAA-AAA-/?
If so you could try something like this example. Note that I haven't fully tested it. So if you see any issues can you reply back with the debug from /var/log/ltm?
when HTTP_REQUEST {
Get the index of the last URI directory
set depth [URI::path [HTTP::uri] depth]
Parse the last directory in the path
set last_dir [URI::path [HTTP::uri] $depth $depth]
Parse everything after the last hyphen in the last directory
set digits [string trimleft [string range $last_dir [expr {[string last - $last_dir]}] end-1] -/]
log local0. "URI=[HTTP::uri], \$depth=$depth, \$last_dir=$last_dir, \$digits=$digits"
Check if we parsed 4 or 6 digits
switch $digits {
[0-9][0-9][0-9][0-9] -
[0-9][0-9][0-9][0-9][0-9][0-9] {
Found 4 or 6 digits, send a redirect
HTTP::redirect "http://m.site.com/test/?gid=$digits"
}
}
}
It would be more efficient if you could only perform this URI parsing for specific requests that might have the GID in the path. Do the requests always start with a standard path? Or is there another way that you could limit when you check for the 4 or 6 digits?
Aaron