Vince_Beltz_959
Feb 12, 2009Nimbostratus
HTTP Redirect
What I need to do is rewrite any incoming HTTP request for specific domains that has either nothing or just a / after the TLD into the form http://www.domain.com/label/ws/index. Requests that have a longer URI should be passed without change. The rule has to be specific for each domain instead of just pasting the domain into the URI because they don't always match (the first elseif is for domainb pointing to a labelx). Using the iRule editor, I'm getting parse errors on lines 5 and 11 (syntax 112). I'm sure I'm making some kind of very basic mistake - help?
when HTTP_REQUEST {
[ string tolower [HTTP::host] ]
if { ( [HTTP::host] ends_with "domaina.com" ) and ( string length [HTTP::uri] < 2 ) } {
HTTP::redirect "http://www.domaina.com/labela/ws/index"
}
elseif { ( [HTTP::host] ends_with "domainb.com" ) and ( string length [HTTP::uri] < 2 ) } {
HTTP::redirect "http://www.domainb.com/labelx/ws/index"
}
elseif { ( [HTTP::host] ends_with "domainc.com" ) and ( string length [HTTP::uri] < 2 ) } {
HTTP::redirect "http://www.domainc.com/labelc/ws/index"
}
}