Forum Discussion
URI based 301 redirection to alternate Virtual Server
I am a novice when it comes to working with iRules, and I have a need to redirect incoming http requests from the default virtual-server to an alternate VS only if the contents of the uri match a certain criteria, and maintain the uri while the host is redirected. I am asking for syntax checking to see if the iRule I have built will work for what I am needing.
The default vip the requests would be coming in on as an example would be ";.
when HTTP_REQUEST {
if { [HTTP::path] starts_with "/~blahcomm" } {
HTTP::respond 301 Location "http://vipweb.prod.blah.com[HTTP::path]"
}
elsif { [HTTP::path] starts_with "/blahwide" } {
HTTP::respond 301 Location "http://vipweb.prod.blah.com[HTTP::path]"
}
}
2 Replies
- Stephane_Viau
Nimbostratus
It looks fine :) However since both "if" do the same thing, you could group them together. Ex :
if { (HTTP::path] ...) or (HTTP::path] ...) }
But otherwise it should work. You can also replace [HTTP::path] by [HTTP::uri] in the redirection if you also wish to keep the query string.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
