Feb 05, 2010
One Vs for Redirects
This should be an easy one..
I want to use one VS for a bunch of redirects, a catch all of sorts.. If for some reason this is a bad idea just let me know.
The redirect on...
Step 1: I created a data group called 'dc-post' and added two entries - note that I left the 'value' field blank.
"www.foo.com www.google.com"
"www.bar.com www.yahoo.com"
when HTTP_REQUEST {
set Host [findclass [HTTP::host] dc-post " "]
log local0. "Host var is $Host"
if { $Host ne "" } {
HTTP::redirect http://$Host[HTTP::uri]
}
}
Note that there's one change to the rule above: I added the 'http://' to the redirect. It'll work either way, but my original rule was confusing (for it to work you'd need to specify 'http://www.foo.com' in your data group for the first field as opposed to just the hostname). Sorry for the confusion on that.
At any rate, this appears to be working fine. Please let me know if you still have problems.
-Matt