when RULE_INIT {
set ::org "O=xyzcompany"
log "desired host.xyzcompanyresources.com_irule initialized"
}
when HTTP_REQUEST {
set destination_path "pages/legacyredirection.aspx?legacyurl="
set destination_host "stageamericas.internal.xyzcompanyonline.com/"
Check if requested host starts with desired host.xyzcompanyresources.com
if {([string tolower [HTTP::host]] starts_with $::communities_host_list)} {
set content [string tolower [HTTP::uri]]
set redirect_to "${destination_host}${destination_path}[HTTP::host]${redirect_uri}"
if {$redirect_uri ne ""}{
HTTP::redirect https://$redirect_to
}
}
}
it worked - came in the next day and they say it doesn’t work anymore
my data group list is called communities_host_list
Hi BuccaneerDave. I’d start a little smaller. Some thoughts
I don’t know how that would have worked because redirect_uri variable isn’t even defined (did you mean content?)
In the age of CMP (clustered multi-processing) you should avoid global variables at all costs as it pins your virtual server traffic to one tmm instance.
Unless you are supporting scripts/custom non-compliant tools as clients, you don’t need to set the host to lower case, browsers will do this automatically per standard. Also, note that the HTTP::host command returns only the fqdn unless your virtual is on a non-standard 80/443 port, in which case it will return fqdn:
Variables can be helpful when you are getting started to provide clarity, but given the simplicity of this effort, you really shouldn’t use them.
If you are going to have many hosts to re-map, a datagroup is a good idea, but you’ll need to use the class command to extract the data. Also, I’d recommend setting the old host as the key and the new host as the value in that datagroup so you can keep all the data separate from the logic of the iRule.
I’ve made some assumptions of what I think you are attempting here. Given the specifics of your example, the code below should work for you.
hope this helps sir.
when HTTP_REQUEST {
if { [HTTP::host] equals "hostA.xyzcompanyresources.com" } {
HTTP::redirect https://stageamericas.internal.xyzcompanyonline.com/pages/legacyredirection.aspx?legacyurl=[HTTP::host][HTTP::uri]
}
}
9.4.0 - 9.4.3, class reference not compatible as of 9.4.4, "::" and "$::" prefixes are no longer required to reference classes using findclass or matchclass. Classes are static and are therefore CMP compatible. There is no need to treat them as global objects.
CMP Compatibility
can you try this?
if { [class match -- [HTTP::host] equals communities_host_list] } {
...
}