Forum Discussion
hooleylist
Mar 02, 2010Cirrostratus
So maybe something like this?
when HTTP_REQUEST {
Check if the subdomain starts with www. or is null
if {[string tolower [HTTP::host]] starts_with "www." or [HTTP::host] eq ""}{
Exit this event in this rule
return
}
log local0. "Host didn't start with www: [HTTP::host]"
Save the first directory in the HTTP path, set to lower case
set first_dir [string tolower [getfield [HTTP::path] "/" 2]]
Check if the first directory matches some pattern like "product"
if {not ($first_dir starts_with "product")}{
Exit this event in this rule
return
}
log local0. "\$first_dir, $first_dir, matched the pattern check"
Check if the first directory in the path is not the same as the subdomain
if {$first_dir ne [getfield [string tolower [HTTP::host]] "." 1]}{
log local0. "Redirecting request to $first_dir.xyz.com"
HTTP::redirect "$first_dir.xyz.com"
}
}
}
Aaron