Forum Discussion

Jaz_170005's avatar
Jaz_170005
Icon for Nimbostratus rankNimbostratus
May 01, 2015

net::ERR_TOO_MANY_REDIRECTS

Hello,

 

I am facing challenges with writing an iRule...I have one host that host multiple site ( or pages which is pointing to domino DB).

 

I have about 15 site, here are few to keep it simple : https://host1.com https://host1.com/newlga.nsf https://host1.com/marine/pullmantursqm.nsf https://host1.com/marine/sqm.nsf https://host1.com/mail/hteam.nsf

 

iRule is: when HTTP_REQUEST { log local0. "Hi-------------------" set host [string tolower [HTTP::host]] set uri [HTTP::uri] if { $host equals "host1.com" and ( $uri equals "" ) } { set uri "/newlga.nsf/frHomePage?" log local0. "uri = $uri ******* " pool PRD_landedgoods_Pool HTTP::redirect "https://$host$uri" } if { $host equals "host1.com" and ( $uri equals "/newlga.nsf" ) } { set uri "/newlga.nsf/frHomePage" log local0. "uri = $uri ******* " pool PRD_landedgoods_Pool HTTP::redirect "https://$host$uri" } if { $host equals "host1.com" and ( $uri equals "/marine/pullmantursqm.nsf" ) } { set uri "/marine/pullmantursqm.nsf" log local0. "uri = $uri ******* " pool PRD_landedgoods_Pool HTTP::redirect "https://$host$uri" } if { $host equals "host1.com" and ( $uri equals "/marine/sqm.nsf" ) } { set uri "/marine/sqm.nsf" log local0. "uri = $uri ******* " pool PRD_landedgoods_Pool HTTP::redirect "https://$host$uri" } if { $host equals "host1.com" and ( $uri equals "/mail/hteam.nsf" ) } { set uri "/mail/hteam.nsf" log local0. "uri = $uri ******* " pool PRD_landedgoods_Pool HTTP::redirect "https://$host$uri" } }

 

the first two urls works fine and bring up the corresponding page, however all the rest , throws this erro: This webpage has a redirect loop ERR_TOO_MANY_REDIRECTS

 

thank you for your help in advance.

 

8 Replies

  • You don't need a redirect that creates the loop. Setting the URI and pool is enough if I undertand the requirement correctly. You might be able to simplify with switch cmd.

    when HTTP_REQUEST {
            log local0."Hi-------------------" 
            set host [string tolower [HTTP::host]]
            set uri [HTTP::uri]
            if { $host equals "host1.com" and ($uri equals "") } {
                set uri "/newlga.nsf/frHomePage?" 
                log local0. "uri = $uri ******* " 
                HTTP::uri $uri
                pool PRD_landedgoods_Pool       
            }
            .............       
    }
    
  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    You don't need a redirect that creates the loop. Setting the URI and pool is enough if I undertand the requirement correctly. You might be able to simplify with switch cmd.

    when HTTP_REQUEST {
            log local0."Hi-------------------" 
            set host [string tolower [HTTP::host]]
            set uri [HTTP::uri]
            if { $host equals "host1.com" and ($uri equals "") } {
                set uri "/newlga.nsf/frHomePage?" 
                log local0. "uri = $uri ******* " 
                HTTP::uri $uri
                pool PRD_landedgoods_Pool       
            }
            .............       
    }
    
  • this is switch example.

    /marine/pullmantursqm.nsf, /marine/sqm.nsf and /mail/hteam.nsf uri are not changed, so i removed them from switch pattern. also, i removed pool because all uris are sent to the same pool (i.e. pool can be assigned to virtual server).

    when HTTP_REQUEST { 
      if { [HTTP::host] equals "host1.com" } {
        switch [string tolower [HTTP::uri]] {
          "/" {
            HTTP::uri "/newlga.nsf/frHomePage?" 
          } 
          "/newlga.nsf" {
            HTTP::uri "/newlga.nsf/frHomePage" 
          } 
        }
      }
    }
    
  • this is switch example.

    /marine/pullmantursqm.nsf, /marine/sqm.nsf and /mail/hteam.nsf uri are not changed, so i removed them from switch pattern. also, i removed pool because all uris are sent to the same pool (i.e. pool can be assigned to virtual server).

    when HTTP_REQUEST { 
      if { [HTTP::host] equals "host1.com" } {
        switch [string tolower [HTTP::uri]] {
          "/" {
            HTTP::uri "/newlga.nsf/frHomePage?" 
          } 
          "/newlga.nsf" {
            HTTP::uri "/newlga.nsf/frHomePage" 
          } 
        }
      }
    }