Forum Discussion
Mar 17, 2014
Hi Brett!
Depending on how the rest of your iRule looks like and how many cases you have in the switch personally I'd probably go for a class search.
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { [class search test_redirects starts_with $uri] or $uri equals "/test/" } {
HTTP::redirect "http://redirected.server.com[HTTP::uri]"
}
}
"test_redirects" is a data group list of the type string and would contain "/test/", "/test1/", etc. The iRule above keeps the CMP intact and saves you some resources.
You could also use a data grouplist for the URI's without trailing slash, but if you only have the one, "/test", I'd keep "or" instead, like the example above.
Good luck!
/Patrik