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

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

iRule Assistance with redirecting multiple URLs to a single URL using an existing Redirect iRule

I currently have a universal redirect and have a requirement to add the below to this irule. Since I am unfamiliar with irules I am hoping a DevCentral community expert can assist.

I need to redirect these urls http://sitename.com, https://sitename.com, http://www.sitename.com & https://www.sitename.com

To this url https://www.sitename.io

Our current irule looks like this with several entries inside the beginning HTTP_REQUEST.

when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {   
  "*www.sitename.net*" {
     HTTP::redirect "https://sitename.sitename.com"
  }
  default {
     # add the default action you prefer ie "www.def.com"
     HTTP::redirect "https://[HTTP::host][HTTP::uri]"
    }
  }
}    
0
Rate this Question
Comments on this Question
Comment made 24-Sep-2018 by jpeterson6 181

Assuming you want to keep www.sitename.net, the following additional entry should cover the four examples you listed:

when HTTP_REQUEST {
   switch -glob [string tolower [HTTP::host]] {   
      "*www.sitename.net*" {
         HTTP::redirect "https://sitename.sitename.com"
      }
      "*sitename.com" {
         HTTP::redirect "https://www.sitename.io"
      }
      default {
         # add the default action you prefer ie "www.def.com"
         HTTP::redirect "https://[HTTP::host][HTTP::uri]"
      }
   }
}
0
Comment made 24-Sep-2018 by bwilliam 171

Thank you. A simple wildcard does the trick, go figure. I guess that makes sense given the sitename.com is static and we only want to trigger the redirect if any of the variables preceding sitename.com changes.

0

Answers to this Question