Forum Discussion
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...
hoolio
Cirrostratus
Mar 02, 2010Can you try something like this with a datagroup containing the original host header value, a space and then the host to redirect to on a single line?
when HTTP_REQUEST {
Log the request details
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] to [HTTP::host][HTTP::uri]"
Check if the requested host is in the my_hosts_class datagroup
The my_hosts_class should be a datagroup containing the host to match on
and the host to redirect to separated by a space:
host_orig_1 host_new_1
host_orig_2 host_new_2
set host [findclass [string tolower [HTTP::host]] $::my_hosts_class " "]
Check if there was a match
if {$host ne ""}{
log local0. "[IP::client_addr]:[TCP::client_port]: Matched $host"
HTTP::redirect "http://$host[HTTP::uri]"
} else {
HTTP::respond 200 content " Sorry, no match "
log local0. "[IP::client_addr]:[TCP::client_port]: No match"
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects