Forum Discussion

senthil147_1421's avatar
senthil147_1421
Icon for Nimbostratus rankNimbostratus
Jul 18, 2014

IRULE HTTP Redirection

Hi Team,

 

I need to configure URI redirection as below . Can you Please help me to create IRULE Please

 

http://abc.com/xxx/* to http://xyz.com/xxx/* . Here * should have same value even after redirection meaning if user connects to http://abc.com/xxx/123 F5 should redirect to http://xyz.com/xxx/123 . Also Client browser should display original URL (http://abc.com/xxx/*) not the redirected URL.

 

Your assistance will be highly appreciated .

 

Thanks, Senthil

 

7 Replies

  • Senthil, can you provide a little more info on your setup? Are abc.com and xyz.com both VIPs on your F5? Are you redirecting all the requests or just a specific path?

     

  • Thanks for your reply Eugene.

     

    xyz.com is external link its not VIP in our F5. Redirection required for all the requests to this URL http://abc.com/xxx/* . So anything comes after xxx/* should be redirected. i have given below examples

     

    Example 1:

     

    http://abc.com/xxx/community/ http://xyz.com/xxx/community/

     

    Example 2:

     

    http://abc.com/xxx/test/ http://xyz.com/xxx/test/

     

    Thanks, Senthil

     

  • You are looking for a rewrite, not redirection. Try something like this.

    when HTTP_REQUEST { 
         set http_host [string tolower [HTTP::host]]
         switch $http_host { 
             "abc.com" { 
                 HTTP::host xyz.com
                 return 
             }
    
  • Hi bepsoccer,

     

    Thanks your reply. I do not want to match only domain abc.com. rewrite or redirection has to be done for abc.com/xxx not for main domain abc.com.

     

    Can you Please help me ?

     

    Thanks, Senthil

     

  • Try something like this.

    when HTTP_REQUEST { 
     set http_host [string tolower [HTTP::host]]
     if { [string tolower [HTTP::host]]  equals  "abc.com" }{ 
        switch -glob $uri {
            "xxx" { HTTP::host xyz.com
                return }
        }
     }
    
  • HI,

     

    I tried creating this IRULE but getting Error.Attached the screenshot.

     

    Thanks, Senthil

     

  • lkchen's avatar
    lkchen
    Icon for Nimbostratus rankNimbostratus

    How about something like this:

    when HTTP_REQUEST { 
      if { [string tolower [HTTP::host]] equals "abc.com" }{
          switch -glob [HTTP::uri] {
            "/xxx" -
            "/xxx/*" {
              HTTP::host xyz.com
              return
            }
          }
      }
    }