Hi Göran,
you may try either a nested
[switch]
or
[if]
condition to parse the HOST and then the Path (general purpose) or use a combined [if] condition (tailordered purpose).
Example 1: Using general purpose nested [switch]
commands.
when HTTP_REQUEST {
switch -glob -- [string tolower [HTTP::host]] {
"www.domain.de" {
Requests for www.domain.com
switch -glob -- [string tolower [HTTP::path]] {
"/" {
Requests for URI = /
HTTP::redirect "/abc/"
}
default {
Requests for URI = *
}
}
}
"www.domain.com" {
Requests for www.domain.com
}
"www.domain.net" {
Requests for www.domain.net
}
default {
Unknown HOST-name
}
}
}
Example 2: Using general purpose nested [if]
commands.
when HTTP_REQUEST {
set low_host [string tolower [HTTP::host]]
if { $low_host eq "www.domain.de" } then {
Requests for www.domain.de
set low_path [string tolower [HTTP::path]]
if { $low_path equals "/" } then {
Requests for URI = /
HTTP::redirect "/abc/"
} else {
Requests for URI = *
}
} elseif { $low_host equals "www.domain.com" } then {
Requests for www.domain.com
}
} elseif { $low_host equals "www.domain.net" } then {
Requests for www.domain.net
} else {
Unknown HOST-name
}
}
Example 3: Using a tailordered [if]
command (to support just your requirements)
when HTTP_REQUEST {
if { ( [string tolower [HTTP::host]] equals "www.domain.de" )
and ( [HTTP::path] equals "/" } then {
Requests for www.domain.de/
HTTP::redirect "/abc/"
} else {
Request for another HOST-name or another Path
}
}
Note: The general purpose examples can be easily extended to support various other things. The benefit of such a syntax is that you get scalable and unified method to control your traffic as needed.
Cheers, Kai