Forum Discussion
Irule Datagroup redirect
I am using this iRule
when HTTP_REQUEST {
if { [class match [string tolower [HTTP::host][HTTP::uri]] starts_with test] } {
set redirect_value [class match -value [string tolower [HTTP::host][HTTP::uri]] equals test]
HTTP::respond 301 Location "https://$redirect_value"
}
}
while my datagroup looks like
https://www.abc.ca/marrow/Overview > https://test.abc.ca/stashtest
https://www.abc.ca/marrow/Sponsors > https://xyz.ca.ca/stashbwards/list
I am expecting that when someone hist the VIP with https://abc.ca/marrow/Overview?changeLocale=en_CA VS https://www.abc.ca/marrow/Overview then it will still redirected to https://test.abc.ca/stashtest
but that does not seem to work.
I am not sure what to change to make it work. Any help will be much appreciated.
If you want to match regardless of the query string, use [HTTP::path] instead of [HTTP::uri]
And if you have different cases of what is to be matched, split them up by type, e.g. one datagroup and if/elseif condition for starts_with, one for exact match, one including query string, etc.
Or use the datagroup for your "default" case and hardcode the exceptions in your iRule if it's just a handful.
Depends on your preference, how many redirects there are and how often you expect them to change.
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