Forum Discussion
Venkat_96085
Nimbostratus
Apr 24, 2009URL Redirection
Hi friends,
I am a newbie to iRules and neither a coder. i have the following scenario and i need irules for this.
When some user connects to a URL say example: www.xyz.com the user has to get redirected to www.xyz.com/search/home.asp
Similarly when somebody connects to a URL www.xyz.com/fslink the user has to get redirected to www.xyz.com/search/home.asp
Appreciate if you can send me the iRules for the above.
Thanks,
Venkat
3 Replies
- hoolio
Cirrostratus
Hi Venkat,
You can use HTTP::redirect command (Click here) to redirect the client. You would want to check if the request was to the root document (/) or fslink before redirecting:when HTTP_REQUEST { Check if request is to / or /fslink switch [string tolower [HTTP::path]] { "/" - "/fslink" { Redirect client HTTP::redirect "http://www.xyz.com/search/home.asp" } } }
If you want the client to not see the change in the path, you could rewrite the URI using HTTP::path (Click here).
Aaron - Venkat_96085
Nimbostratus
Hi Aaron,
Thanks for your reply. i made little bit of modifications to the iRules can you tell me if this is correct.
1. When somebody connects to www.xyz.com, he gets redirected to www.xyz.com/index.html
2. when somebody connects to www.xyz.com/fslink, he gets redirected to www.xyz.com/search/home.asp
3. when somebody connects to www.xyz.com/doc, he gets redirected to www.xyz.com/doc.html
Can you tell me if the below irules are correct. Thanks for your help.
when HTTP_REQUEST {
Check if request is to / or /fslink
switch [string tolower [HTTP::path]] {
"/" {
HTTP::redirect "http://www.xyz.com/index.html"
}
"/doc" {
HTTP:: redirect "http://www.xyz.com/doc.html"
}
"/fslink" {
Redirect client
HTTP::redirect "http://www.xyz.com/search/home.asp"
}
}
} - hoolio
Cirrostratus
That looks good.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
