I might be wrong, but your first example and your rule does not seem to match?
It has not been tested, but this rule should turn http://example.bleh.com to http://example.bleh.com/example.
when RULE_INIT {
set static::domain ".jbhunt.com"
}
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
if { [[HTTP::host] contains $static::domain }{
Get the first field of the host split by "."
set subdomain [getfield [HTTP::host] "." 1]
Change the uri
HTTP::uri "/$subdomain"
}
}
}
Two tips:
- Static is good practice for variables that's not going to change.
- The host header comes in lower case, so there's no need to actually use string to lower.
- I did not see a reason to validate "" against the subdomain variable since you are checking if the host contains ".jbhunt.com". That would would validate that there is a sub domain, right?
/Patrik