Forum Discussion
Bryan_Chick_152
Nimbostratus
Aug 18, 2006Redirect based on position of word in uri
Hi all,
I posted a question a couple days ago, but mispoke in the question. I am posting the modified question here again as a new post.
I need a rule that redirects for a certain word within the uri--but only under specific circumstances regarding the position of that word within the uri. We would like a redirect to occur in all situations excluding when a word in included between the uri and url.
Examples:
1.) http://vw.com/golf => Should redirect to http://vw.com/rabbit
2.) http://vw.com/golf/(anything else appended to uri) => Should redirect as above example to http://vw.com/rabbit
3.) http://vw.com/(something)/golf => Should NOT redirect.
Thanks!
Bryan
- You've been presented with some if statements, here's a switch option you can use that should do what you want.
when HTTP_REQUEST { switch -glob "[HTTP::host][HTTP::uri]" { "vw.com/golf" - "vw.com/golf/*" { HTTP::redirect "http://vw.com/rabbit" } } }
when HTTP_REQUEST { if { "[HTTP::host][HTTP::uri]" starts_with "vw.com/golf" } { HTTP::redirect "HTTP://vw.com/rabbit" } }
- Bryan_Chick_152
Nimbostratus
Thanks Joe for the quick response! - In 4.x, you don't have the fun switch statements, so you'll have to fall back to a plain old if statement.
if ((http_host equals "vw.com") and (http_uri starts_with "/golf")) { redirect to "http://vw.com/rabbit" }
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