Search a URI for ~ followed by a number?

Gang,

Running 11.5.3 on my LTMs, and I’m trying to find an iRule that will block access to any URI that begins with “/this_is_where_I_start/”, then contains “~any_number” within the URI. For instance, I’d like to block “http://thisismysite.com/this_is_where_I_start/lots_of_directories/filename~1.fileextension” The key here is the ~1. Is the recommendation going with a regex variable, or a string variable?

Thanks in advance.

Joe

is scan useful?

e.g.

% set u1 /this_is_where_I_start/lots_of_directories/filename~1.fileextension
/this_is_where_I_start/lots_of_directories/filename~1.fileextension
%
% set u2 /this_is_where_I_start/lots_of_directories/filename.fileextension
/this_is_where_I_start/lots_of_directories/filename.fileextension
%
% scan $u1 {%*[^~]~%d} num1
1
% put $num1
1
%
% scan $u2 {%*[^~]~%d} num2
0

Nitass,

That looked pretty crazy. Here’s what I came up with:

when HTTP_REQUEST { if { [string tolower [HTTP::path]] starts_with “/this_is_where_I_start/” and [HTTP::uri] matches_regex {/~[0-9]}} { reject } }

The iRule didn’t bomb on me, so I’m going to apply it in my test environment. Do you see any potential gotchas there?

Joe