Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

irule - allow only a few URLs under a directory

Hi - We have a site where the policy allows all URLs with * wildcard. We were recently asked to disable access to all URLs under a certain single directory except for a few URLs.

Since the "Disallow URLs" option doesn't permit using WCs, I need a different solution.

Sadly I am still new to iRULES and I searched and found other solutions but not something as specific as this.

Any help would be greatly appreciated.

Thanks, Vered

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi Guy,
Use this iRule :

when HTTP_REQUEST {
	switch -glob [string tolower [HTTP::uri]] {
		"/root_dir/disallowed_dir1*" -
		"/root_dir/disallowed_dir2*" -
		"/root_dir/disallowed_dir3*"
		{
			# drop the request or send code 403 to the user
			drop
		}
		"/*"
		{
			# do nothing for rest, send them to servers
		}
	}
}

or use that :

when HTTP_REQUEST {
    if { ( [string tolower [HTTP::uri]] starts_with "/root_dir/disallowed_dir1" ) or ( [string tolower [HTTP::uri]] starts_with "/root_dir/disallowed_dir2" ) or ( [string tolower [HTTP::uri]] starts_with "/root_dir/disallowed_dir3" ) } {
        drop
     }
}
0
Comments on this Answer
Comment made 3 months ago by Faruk AYDIN 776

Hope it helps

Please mark it as answer if it works

Regards

0