Forum Discussion
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
2 Replies
- nitass
Employee
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 - Joe_Erchul_4263
Nimbostratus
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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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