Forum Discussion

js55161_47239's avatar
js55161_47239
Icon for Nimbostratus rankNimbostratus
Apr 22, 2008

HTTP Redirect

Can someone tell me where i am going wrong with the following irule please? The BIG-IP ltm doesn't like the redirect command so what can i use instead?

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] contains "ShP/anqmemlogin.jsp"} {

 

redirect "https://wwwpp20.landg.com/ManageYourAccountWeb/ENTRY_POINT"

 

}

 

elseif {[HTTP::uri] contains "bpcentre"} {

 

redirect "https://wwwpp20.landg.com/BPCentre/docbase/bpcentre/index.hml"

 

}

 

elseif {[HTTP::uri] contains "ShP"} {

 

pool wwwpp20.landg.com

 

}

 

elseif {[HTTP::uri] contains "DocumentLibraryWeb"} {

 

pool wwwpp20.landg.com

 

}

 

elseif {[HTTP::uri] contains "ShPSchemeAdmin"} {

 

pool wwwpp20.landg.com

 

}

 

elseif {[HTTP::uri] contains "cehttp"} {

 

pool wwwpp20.landg.com

 

}

 

elseif {[HTTP::uri] contains "CAWeb"} {

 

pool ppentry.landg.com

 

} else {

 

pool ppentry.landg.com

 

}

 

}

 

 

Many Thanks

5 Replies

  • This is what i have changed it to after your suggestion ...

     

    when HTTP_REQUEST {

     

    if {[HTTP::uri] contains "ShP/anqmemlogin.jsp"} {

     

    [HTTP::redirect] "https://wwwpp20.landg.com/ManageYourAccountWeb/ENTRY_POINT"

     

    }

     

    elseif {[HTTP::uri] contains "bpcentre"} {

     

    [HTTP::redirect] "https://wwwpp20.landg.com/BPCentre/docbase/bpcentre/index.hml"

     

    }

     

    elseif {[HTTP::uri] contains "ShP"} {

     

    pool wwwpp20.landg.com

     

    }

     

    elseif {[HTTP::uri] contains "DocumentLibraryWeb"} {

     

    pool wwwpp20.landg.com

     

    }

     

    elseif {[HTTP::uri] contains "ShPSchemeAdmin"} {

     

    pool wwwpp20.landg.com

     

    }

     

    elseif {[HTTP::uri] contains "cehttp"} {

     

    pool wwwpp20.landg.com

     

    }

     

    elseif {[HTTP::uri] contains "CAWeb"} {

     

    pool ppentry.landg.com

     

    } else {

     

    pool ppentry.landg.com

     

    }

     

     

    Still not working and i get the following error ...

     

    01070151:3: Rule [wwwpp80_Redir] error: line 1: [parse error: missing close-brace] [{ if {[HTTP::uri] contains ShP/anqmemlogin.jsp} { [HTTP::redirect] https://wwwpp20.landg.com/ManageYourAccountWeb/ENTRY_POINT } elseif {[HTTP::uri] contains bpcentre} { [HTTP::redirect] https://wwwpp20.landg.com/BPCentre/docbase/bpcentre/index.hml } elseif {[HTTP::uri] contains ShP} { pool wwwpp20.landg.com } elseif {[HTTP::uri] contains DocumentLibraryWeb} { pool wwwpp20.landg.com } elseif {[HTTP::uri] contains ShPSchemeAdmin} { pool wwwpp20.landg.com } elseif {[HTTP::uri] contains cehttp} { pool wwwpp20.landg.com } elseif {[HTTP::uri] contains CAWeb} { pool ppentry.landg.com } else { pool ppentry.landg.com }] line 2: [command is not valid in the current scope] [if {[HTTP::uri] contains ShP/anqmemlogin.jsp} { [HTTP::redirect] https://wwwpp20.landg.com/ManageYourAccountWeb/ENTRY_POINT } elseif {[HTTP::uri] contains bpcentre} { [HTTP::redirect] https://wwwpp20.landg.com/BPCentre/docbase/bpcentre/index.hml } elseif {[HTTP::uri] contains ShP} { pool wwwpp20.landg.com } elseif {[HTTP::uri] contains DocumentLibraryWeb} { pool wwwpp20.landg.com } elseif {[HTTP::uri] contains ShPSchemeAdmin} { pool wwwpp20.landg.com } elseif {[HTTP::uri] contains cehttp} { pool wwwpp20.landg.com } elseif {[HTTP::uri] contains CAWeb} { pool ppentry.landg.com } else { pool ppentry.landg.com }]

     

     

    Any help would be great.

     

    Thanks
  • v9.4.3.

     

    You irule worked fine, so thanks for that. I will use the irule editor in the future as the big-ip ltm error messages are not good. (They must have based this on Microsoft!)

     

     

    Cheers
  • Hi,

    In order to have something more readable you may try to use switch instead of a sequence of if / elseif.

    If you have a lot of check to do switch will become more efficient.

    
    when HTTP_REQUEST {
       switch -glob [HTTP::uri] {
           "*ShP/anqmemlogin.jsp" {
             HTTP::redirect "https://wwwpp20.landg.com/ManageYourAccountWeb/ENTRY_POINT"
           }
           "*bpcentre*" {
             HTTP::redirect "https://wwwpp20.landg.com/BPCentre/docbase/bpcentre/index.hml"
           }
           ...
           default {
             pool ppentry.landg.com
           }  
       }
    }

  • This is a little advanced for me. How can I do a simple redirect to make all https pages resolve to http?