Forum Discussion
DaveC_21078
Altostratus
Aug 27, 2009How can I chab=nge the format of a URL?
I need to be able to search for a URL similar to
http://example.com/adserver/impression/pid=123/oid=860/rand=12345/?click=http://www.publisher.com/track/ad.aspx?click=1&test=2&imp=1
...
hoolio
Cirrostratus
Aug 31, 2009String map won't work with variables wrapped in curly braces. So you can either use subst like Joe listed, or remove the curly braces. Also, Citizen's suggestion was to add a second HTTP request event with a priority of 501 so you could see the effect of the change once it is made. And you'll need to include a leading forward slash in the scan pattern or it won't match any URI.
Can you try this and reply with the log output from /var/log/ltm if it doesn't work expected?
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::uri]"
if { [HTTP::uri] contains "adserver/impression" }{
log local0. "[IP::client_addr]:[TCP::client_port]: Matched URI check"
Scan the URI looking for the pid, oid and rand values
if { [scan [HTTP::uri] "/adserver/impression/pid=%d/oid=%d/rand=%d" pid oid rand] == 3 } {
log local0. "[IP::client_addr]:[TCP::client_port]: Scanned three values: pid = $pid, oid = $oid, rand = $rand"
HTTP::uri [string map "adserver/impression/pid=$pid/oid=$oid/rand=$rand/?click ad.imp?pid=$pid&oid=$oid&rand=$rand/?pclk" [HTTP::uri]]
}
}
}
when HTTP_REQUEST priority 501 {
log local0. "[IP::client_addr]:[TCP::client_port]: 501: Updated URI: [HTTP::uri]"
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects