Forum Discussion

Joe_Pena_46781's avatar
Joe_Pena_46781
Icon for Nimbostratus rankNimbostratus
Jan 25, 2017

irule and redirect exception

we have a domain bankrate.com that redirects all request to , however need to make an exception for a particular URL NOT to redirect. for example: we do not want to redirect http://bankrate.com/filename.html, all other request to http://bankrate.com/* should redirect to http://www.bankrate.com/.

 

Here's my irule currently:

 

when HTTP_REQUEST { switch -glob [HTTP::uri] { "/system/util/email.aspx*" { HTTP::respond 301 Location "; } } switch [HTTP::host] { bankrate.com - { HTTP::respond 301 Location "http://www.bankrate.com[HTTP::uri]" } } }

 

  • iRules are processed in the order in which they are written so if you put your uri exception at the top of the iRule it will be processed before the other redirects.

     

    switch -glob [HTTP::path] { "/filename.html" { pool YOUR_POOL } the rest of your iRule...

     

  • iRules are processed in the order in which they are written so if you put your uri exception at the top of the iRule it will be processed before the other redirects.

     

    switch -glob [HTTP::path] { "/filename.html" { pool YOUR_POOL } the rest of your iRule...

     

  • Oh I see. You have multiple switch statements so it must process the first until it find a match and then process the next where as if it were all under the same switch statement it would stop processing once it found a match. You may try using if/else instead of switch.

     

    if your_file_name { do something } elseif host_to_redirect { redirect } else { default behavior }

     

    If you did this it would stop process on that particular event once it matched on your file name thereby never redirecting.

     

  • Hi,

    you can use this irule

    when HTTP_REQUEST {
        if {[HTTP::host] equals "bankrate.com"} {
            if {[HTTP::uri] equals "/filename.html"} {
                pool MYPOOL
            } else {
                HTTP::respond 301 Location "http://www.bankrate.com[HTTP::uri]"
            }
        }
    }
    
  • this is very difficult question ya . i already face this problem in my site: . But after i take the help my Developer friend he give my some solution . here some code you have a try . i don't it works for site or note: Mortgage Agent Toronto. i agree with Stanislas Piron 5726 its works