Forum Discussion

Diego_23471's avatar
Diego_23471
Icon for Nimbostratus rankNimbostratus
Nov 18, 2013

uri redirects

Can anyone help me complement the irule below to redirect any url not mentioned here to a specific domain ?

 

For example, if user goes to http://mydomain1.org/page1 , it should send him to http://mydomain2.org/page/page1. Any other variation should just send him to the home page, for example; http://mydomain1.org/xyx should redirect to http://mydomain2.org.

 

when HTTP_REQUEST {

 

switch [string tolower [HTTP::uri]] {

 

"/page1.html" { HTTP::redirect "http://mydomain2.org/page/page1.html" } }

 

End of URI pattern case switch

}

 

End of rule

3 Replies

  • You can utilize the default action.

    switch [string tolower [HTTP::uri]] {
      "/page1.html" { HTTP::redirect "http://mydomain2.org/page/page1.html"}
      default { HTTP::redirect "http://mydomain.org" }
      }
    

    Regards, Eric

  • Try this:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] equals "/page1.html" } {
            HTTP::redirect "http://mydomain2.org/page/page1.html"
        } else {
            HTTP::redirect "http://mydomain2.org"
        }
    }
    

    Or

    when HTTP_REQUEST {
        switch [string tolower [HTTP::uri]] {
            "/page1.html" {
                HTTP::redirect "http://mydomain2.org/page/page1.html"
            }
            default {
                HTTP::redirect "http://mydomain2.org"
            }
        }
    }