OK, so the data group named dg_name will contain the hostname to language mappings;
gb:en_GB
de:de_DE
fr:fr_FR
and so on. The dg222_name data group will contain the hostname to sales region mappings;
en:EMEA
de:EMEA
fr:EMEA
The 3 used with the getfield command specifies the value of the third field (as delimited by '.') from the right, so for outlet.ie.XYZ.com the value will be 'ie'.
I've just noticed that for US users only a three part hostname is used so we'll need to account for that too. If the only two regions are US and EMEA we can probable simplify the rule somewhat. Updated rule below;
when HTTP_REQUEST {
Remove any port specification from the hostname and store the result in variable 'hostname'
set hostname [getfield [HTTP::host] ":" 1]
Extract the third element of the hostname (reading from the right) and store result in variable 'subhostname'
set subhostname [getfield $hostname "." 3]
Stop processing this rule if the variable 'subhostname' is empty
if { $subhostname equals "" } { return }
Check if the variable 'subhostname' matches our data group list, if not, redirect to the US site
and stop processing this rule
if { not [class match $subhostname equals "dg_name"] } {
HTTP::redirect "http://outlet.XYZ.com/SEUILibrary/controller/e/outlet_us/XYZPortal/en_US/special-offers.workflow:ShowPromo?LandingPage=/All/US/Portals/Outlet"
return }
Now we're sure we have a valid value for 'subhostname' let's move on
Extract the country URI element as necessary based on the 'subhostname' variable value
set salescountry [class match -value -- $subhostname equals "dg_name"]
Extract the region URI element as necessary based on the 'subhostname' variable value
set salesregion [class match -value -- $subhostname equals "dg222_name"]
Now finally do the redirect
HTTP::redirect "[HTTP::host]/SEUILibrary/controller/e/outlet_$subhostname/XYZPortal/$salescountry/special-offers.workflow:ShowPromo?LandingPage=/All/$salesregion/Portals/Outlet"
}