Forum Discussion
iRule redirect help!
Hi, im looking to create an iRule to do some redirects depending on url requested. I think i have it working but am concerned about the case eg small 'a' or big 'A' as the redirect doesnt work if its different. Does this look correct and is there and easier way i could do this too?
when HTTP_REQUEST {
if {[HTTP::path] eq "/"}{
HTTP::redirect "http://[HTTP::host]/home/live"
} if {[HTTP::path] eq "/a"}{
HTTP::redirect "http://[HTTP::host]/a/"
} if {[HTTP::path] eq "/testinst"}{
HTTP::redirect "http://[HTTP::host]/testinst/"
}
}
Thanks!
3 Replies
- Michael_Jenkins
Cirrostratus
If you were going to use an iRule, I'd suggest something like this. (You can use
to get the lowercase version of a string.[string tolower XXX]when HTTP_REQUEST { switch [string tolower [HTTP::path]] { "/" { HTTP::redirect "http://[HTTP::host]/home/live" } "/a" { HTTP::redirect "http://[HTTP::host]/a/" } "/testinst" { HTTP::redirect "http://[HTTP::host]/testinst/" } default { } } }If you're running 11.4 or later, you could also consider using a Local Traffic Policy instead since this would be a simple rule. (Here's a link on how to create a redirect). Because they're built into the core, local traffic policies are a little more efficient than an iRule.
- cymru81
Altocumulus
thats perfect, thank you!
one more quick question! is there any way to hide the / part of the address when it redirects etc. so all teh user sees is www.domain.com if that makes sense too?
- cymru81
Altocumulus
thats fine,was just a thought!
thank you again for your help.
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