05-Nov-2020 03:43
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:
/myweb/folder1/coronatime
And I what to exclude this uri from datagroup:
/myweb/folder1/coronatime-xyz
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: https://clouddocs.f5.com/api/irules/return.html
Thanks !!
05-Nov-2020 06:34
Instead of starts_with go with equals.
05-Nov-2020 06:48
That's a problem when have hundreds of URI's starting with /myweb/folder1/coronatime
05-Nov-2020 09:00
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.
05-Nov-2020 09:21
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:
/myweb/folder1/coronatime-memo
/myweb/folder1/coronatime-mamo
/myweb/folder1/coronatime-tatoo
etc etc ..
Thanks
06-Nov-2020 07:32
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,
Good luck.