Forum Discussion
Brett__01_13258
Mar 14, 2014Nimbostratus
irule redirect on uri including default location
Im having trouble with requests that i need to redirect based on uri.
My irule is
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/test/" - "/test1/"
{ HTTP::redirect "http:/...
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
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