newf5learner_13
May 18, 2016Nimbostratus
irule to redirect to specific uri..
Hi All,
I need a irule that helps me to redirect users to specific resources / folders on the servers.
I have three servers, all of them hosting sites
https://site1.company.com https://site2company.com https://site3.company.com
All the 3 sites are pointed to load balanced VIP 10.20.20.200
I want a irule that helps me to serve the redirection based on hostname.
if a user tried to access
https://site1.company.com
it should redirect him to https://site1.company.com/USERSITE1/
similarly if a user tries to access
https://site2.company.com
, it should redirect him to https://site2.company.com/MY_USER_SITE/
and thirdly if a user tries to access
https://site3.company.com
, it should redirect him to https://site3.company.com/SITE3/
I tried to use the below url, but its not working as expected.
when HTTP_REQUEST {
set host [string tolower [HTTP::host]]
if { $host contains "site1.company.com"} {
HTTP::redirect "https://site1.company.com/USERSITE1"
} elseif { $host contains "site2.company.com"} {
HTTP::redirect "https://site2.company.com/MYUSERSITE"
} elseif { $host contains "site3.company.com"} {
HTTP::redirect "https://site3.company.com/SITE3"
}
}
thanks in advance for your help.