Forum Discussion
greg_chew_11034
Sep 01, 2005Nimbostratus
rule foo_uris_rule_v2 {
when HTTP_REQUEST {
set host [string tolower [getfield [HTTP::host] ":" 1]]
set uri [string tolower [HTTP::uri]]
set matchstring [substr [substr $uri 1 "?"] 0 "/" ]
if { $matchstring == "" }
{
set matchstring $host$uri
}
else
{
set matchstring $host/$matchstring
}
set redstring [findclass $matchstring $::foo_uris_list " " ]
set query_src [findstr [HTTP::uri] "?src=" 5 "&" ]
if {$query_src == ""}
{
set query_src [findstr [HTTP::uri] "&src=" 5 "&" ]
}
log local0. "query_src = $query_src"
set query_trk_src [findstr [HTTP::uri] "trk_src=" 8 " " ]
log local0. "query_trk_src = $query_trk_src"
if { $query_src != "" }
{
set redstring $redstring&src=$query_src
}
if { $query_trk_src != "" }
{
set redstring $redstring&trk_src=$query_trk_src
}
if {$redstring eq ""}
{
if { $host != "www.foo.com" and $host != "foo.com"}
{
set element [findclass "foo.com/" $::foo_uris_list " " ]
log local0. "Defaulting subdomain to foo.com"
}
}
if {$redstring != ""} {
log local0. "redirecting to $redstring"
HTTP::close
HTTP::redirect $redstring
HTTP::close
event disable all
}
}
}