Forum Discussion
iRule for redirection
Hi,
I am not really familiar with iRule, can somebody help me?
So the scenario is that a user wants to access a f5 vip which will be redirected to a certain site:
user access onboarding.abc.com/uk (f5 vip) and it should redirect to https://ask.service.com/management.do
how can i attain this? it's needs to be exactly as onboarding.abc.com/uk
Thanks!
Policy is always a better choice. I agree with 's iRule. Small correction needed; There is no points to add multiple if condition. Find the below iRule, Hope it will work for you.
when HTTP_REQUEST { if { ([HTTP::host] equals "onboarding.abc.com") && ([HTTP::uri] starts_with "/uk") } { HTTP::respond 301 Location "https://ask.service.com/management.do" } }
Hello ,
You can even achieve your requirement using LTM Policy option. Also you can try below iRule.
when HTTP_REQUEST {
if { [HTTP::host] contains "onboarding.abc.com"}{
if { [HTTP::uri] starts_with "/uk"}{
HTTP::redirect https://ask.service.com/management.do
}
}
}
Hope it works!
Mayur
- KoalanCirrus
thank you guys! i will try this!
- KoalanCirrus
btw whats the difference between that HTTP::respond 301 to the normal redirect ?
HTTP::redirect:- This command always sends an HTTP 302 (Temporary Redirect) status code. HTTP request to the specified URL, or replaces the current response with a redirect to the specified URL.
HTTP::respond:- This command sends a response to the client telling the client to send a fresh request to the URL you specify. A 301 redirect means that the page has permanently moved to a new location.
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