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 03, 2010No problem. It's good that you're making sure you understand how the rule works.
findclass evaluates each line of the datagroup (class) one at a time. It checks the string provided (the host header value set to lowercase) against the first field of the line (with fields delineated by a space: " "). If there is a match, findclass returns the second field in the matching datagroup line. If there is no match, findclass returns a null length string. So $host will be set to either the second field of the match line or nothing.
ne means not equal. So we're checking if $host isn't null with ($host ne "").
I included [HTTP::uri] after the $host in the redirect to include the originally requested URI in the new location being sent to the client. If you just want to redirect the client to the new hostname from the datagroup without a URI, you can take off [HTTP::uri] from the HTTP::redirect command.
For details on the findclass command and TCL operators, you can check the findclass wiki page and the expr man page:
http://devcentral.f5.com/wiki/default.aspx/iRules/findclass
http://www.tcl.tk/man/tcl8.4/TclCmd/expr.htmM13
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
