Forum Discussion
Puneet_73909
Nimbostratus
May 11, 2009Redirection iRule
Hi,
I need help in writing an iRule. I want to read domain name and then redirect it to specific URL.
For example if HHTP::request is for www.domain.com then it will redirect it to www....
The_Bhattman
Nimbostratus
May 11, 2009Hi Puneet,
I believe you can write your logic in the following manner
when HTTP_REQUEST {
set h [HTTP::host]
set u [HTTP::uri]
switch -glob $h {
"www.domain.com" {
HTTP::redirect "http://www.abc.com"
}
"www1.domain.com" {
HTTP::redirect "http://www.xxyz.com"
}
"www.domainname.com" -
"www1.domainname.com" {
switch -glob $u {
"/doc" -
"/minisite" {
HTTP::redirect "http://[HTTP::host]/econ/pages/nm/nmhomepage.jsp"
}
}
}
}
}
Click here to look at the reference to using switch command
However, I am not exactly sure what you mean about your comment
"All requests to http://www.joinDomainName.com gets forwarded to http://www.joinDomainName.com and http://www1.joinDomainName.com gets forwarded to http://www1.joinDomainName.com"
Hope this helps
CB
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
