Technical Forum
Ask questions. Discover Answers.
Showing results for 
Search instead for 
Did you mean: 

excluding specific uri from datagroup


Hello guys


I'm using this iRule to do redirection with data group:

when HTTP_REQUEST { if { [class match [string tolower [HTTP::uri]] starts_with myweb_Uri_Data_group] } {       HTTP::redirect "[class match -value [string tolower [HTTP::uri]] starts_with myweb_Uri_Data_group]"     } }


In the data group I have this uri to be redirected:


And I what to exclude this uri from datagroup:



What is the best way to exclude specific uri ?

is it using another "if" on the top with return statement ?

or there is another way?

Does the "return" exits the specific if function or exits all the irule?

Because it's written here that it does not exit from the iRule altogether:


Thanks !!


Instead of starts_with go with equals.

That's a problem when have hundreds of URI's starting with /myweb/folder1/coronatime

Sorry I'm not following you, We are not going to use starts_with or contains, but be using equals. When equals condition is called it will look for exact match of the entire URI.


Can you tell how many you want to exclude from your original.

And yes you can still create a new DGL for exclusion and then use the return statement to break the flow on the current event.

Sure let me explain again

So you have this DG: myweb_Uri_Data_group and it has URI starts with /myweb/folder1/coronatime . And your website has hundreds of URIs starting with /myweb/folder1/coronatime , and you have only one URI starts with /myweb/folder1/coronatime-xyz that you want to exclude from your DG.

So the only way I can think about is this way:

when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/myweb/folder1/coronatime-xyz } { return } if { [class match [string tolower [HTTP::uri]] starts_with myweb_Uri_Data_group] } { HTTP::redirect "[class match -value [string tolower [HTTP::uri]] starts_with myweb_Uri_Data_group]" } }

So my question: Is this the best solution or there is another best solution to exclude this specific URI ?

And another question - in general- should the "return' exits the entire irule or only the related "if" function?


Your suggestion regarding "equal" is not helping here .. because I have another hundreds of URIs starting with "/myweb/folder1/coronatime" such as:




etc etc ..



Yes the above logic would work too. Basically when you call return, if would stop further processing on that event. Here its HTTP_REQUEST. But note this will stop for this Irule alone. If there's other Irule mapped to the VS, they will still function


There's multiple options you can go,

  1. Use if/elseif option. Whichever URI's you want to be excluded, you can create a new datagroup for that and call it in the 1st if condition. Whether you want to go with starts_with or equals is purely your design call. In that way, when 1st if is passed, further elseif wont be processed. When it not matches, it goes to elseif, and checks with the other DG you have, in your case myweb_Uri_Data_group.
  2. Yes you can use return to stop further process of this event as well.


Good luck.