Forum Discussion
Irule Datagroup redirect
if i want to incorporate case insensitivity into this; will i need to tweak the irule or Datagroup?
what that tweak will be? This is the iRule i am using currently
- when HTTP_REQUEST {
- if { [class match [HTTP::host][HTTP::uri] equals test1] } {
- set redirect_value [class match -value [HTTP::host][HTTP::uri] equals test1]
- HTTP::respond 301 Location "https://$redirect_value"
- }
- }
- Nov 04, 2019
If you want case sensitivity, datagroup strings sholud be lower case. And you can use this iRule.
when HTTP_REQUEST { if { [class match [string tolower [HTTP::host][HTTP::uri]] equals test1] } { set redirect_value [class match -value [string tolower [HTTP::host][HTTP::uri]] equals test1] HTTP::respond 301 Location "https://$redirect_value" } }
You don't need to change datagroup values(redirect_value). They can be contains upper case.
- baboo1970Nov 04, 2019
Altostratus
Thanks very much. this worked and now moving onto next challenge as current one is doing exact match in DataGroup but what if requested URL or Destination is not exact match but something starts_with or contains etc... Don't even know where to start with this as i don't know what is actual structure of the HTTP request.
- baboo1970Nov 05, 2019
Altostratus
Hi I have one more question see if you can help
https://www.abc.ca/marrow/Overview > https://test.abc.ca/stashtest
https://www.abc.ca/marrow/Sponsors > https://xyz.ca.ca/stashbwards/list
https://www.abc.ca/marrow/Sponsors?N=105098 > https://xyz.ca.ca/stashbwards/list?stash_bward_filter=boucher
https://www.abc.ca/marrow/Sponsors?N=105099 > https://xyz.ca.ca/stashrewards/list?stash_bward_filter=in-store
https://www.abc.ca/marrow/SponsorsDetails?Nr=vendor.id:100218 > https://xyz.ca.ca/stashrbwards/touterer/88991
https://www.abc.ca/marrow/SponsorsDetails?Nr=vendor.id:100245 > https://xyz.ca.ca/stashrbwards/boucher/89021
https://www.abc.ca/marrow/BewardsProductList?a=true&selectedCategoryId=cat70001 > https://xyz.ca/merks
So I have these URLs; except the last one all other can come as something like
https://www.abc.ca/marrow/Overview?changeLocale=en_CA
So I am thinking to use somehting like
if { [class match [string tolower [HTTP::host][HTTP::uri]] starts_with test] } {
but the last one
https://www.abc.ca/marrow/BewardsProductList?a=true&selectedCategoryId=cat70001 > https://xyz.ca/merks
has to be exact match; as there can be cat70002; cat 70003 but I only want to redirect cat70001.
Can this be done in same iRule as below or I have to create second iRule to parse the static one and use this one for rest?
- when HTTP_REQUEST {
- if { [class match [string tolower [HTTP::host][HTTP::uri]] equals test1] } {
- set redirect_value [class match -value [string tolower [HTTP::host][HTTP::uri]] equals test1]
- HTTP::respond 301 Location "https://$redirect_value"
- }
- }
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