Forum Discussion
mattias_56723
Nimbostratus
Sep 10, 2009simple filter question of uri
If I want to filter out "?listall=1" and also "log=0" in the uri.
ex: http://testsite.com/test.aspx?listall=1?log=0
to http://testsite.com/test.aspx
How will the syntax look like...
hoolio
Cirrostratus
Sep 11, 2009Hi Max,
You can rewrite the URI inline using a rule like this. It's untested, so try to add logging if you run into any issues. You may also want to add a check if you only need to look for the nocache and listall parameters in requests to specific paths. You could do this by adding a check for [string tolower [HTTP::path]] eq "/test.aspx".
when HTTP_REQUEST {
Debug logging
log local0. "[IP::client_addr]:[TCP::client_port]: New [HTTP::method] request to [HTTP::uri]"
Check if client is not in internal range
if {not ([IP::addr [IP::remote_addr] equals 10.0.0.0/8])} {
Save copy of URI
set uri_tmp [HTTP::uri]
Check if URI contains nocache=1
if {[URI::query [HTTP::uri] nocache] == 1}{
Save updated URI with nocache removed
set uri_tmp [string map {nocache=1 ""} [HTTP::uri]]
}
Check if list parameter is set with any value
if {[URI::query [HTTP::uri] list] ne ""}{
Save updated URI without list parameter and value
set uri_tmp [string map [list "list=[URI::query [HTTP::uri] list]" ""] $uri_tmp]
}
Clean up any double delimiters from $uri_tmp and update the URI
HTTP::uri [string map {?& ? && &} $uri_tmp]
}
}
when HTTP_REQUEST priority 501 {
Debug logging
log local0. "[IP::client_addr]:[TCP::client_port]: Current 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
