Forum Discussion
CAMES_13251
Jun 20, 2011Nimbostratus
Remove URI if it doesn't match my options?
Hi All,
I'm quite new to irules, and can't get something working that should be quite simple.
What I am trying to do is redirect the request based on a couple of key words in the U...
hooleylist
Jun 20, 2011Cirrostratus
If you want to set the URI you'd use HTTP::uri "/new_uri". The square braces force the interpreter to run HTTP::uri as a command and substitute the value. So you'd get a runtime error with that.
Also, it would make sense to rewrite the URI only if the first two cases aren't matched. Can you try moving the HTTP::uri command to a default case in the switch statement:
when HTTP_REQUEST {
Check the requested URI set to lowercase
switch -glob "[string tolower [HTTP::uri]]" {
"/test1" {
Requested URI /test1
HTTP::respond 301 Location "http://www.testone.com/"
}
"/test2" {
Requested URI /test2
HTTP::respond 301 Location "http://www.testtwo.com/"
}
default {
HTTP::uri "/"
}
}
}
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