Generic Host To Uri Mapping

Problem this snippet solves:

This iRule illustrates how to dynamically map the company within the host portion of the HTTP request to cause a redirect to a custom uri starting with that company name.

This iRule uses the findclass command to search a data group for the given company name and, if found, extracts the path mapping and issues a redirect based on that value.

NOTE: findclass command has been deprecated since BIGIP v10

Code :

class valid_company_mappings {
  "A mapping_for_a"
  "B mapping_for_b"
  "C mapping_for_c"

  # -- domain ==, company == A
  regexp {\.([\w]+)\.com} [HTTP::host] domain company
  if { "" ne $company } {
    # look for the second string in the data group
    set mapping [findclass $company $::valid_company_mappings " "]
    if { "" ne $mapping } {
      HTTP::redirect "$mapping"
Published Mar 17, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment