Forum Discussion

mikegray_198028's avatar
Dec 04, 2015

combaine two irules

Help me to combine these two irules.


**1. first irule for pop window**

when HTTP_REQUEST {

if { [HTTP::host] equals "192.168.210.1" and [HTTP::uri] starts_with "/sasi" and ![HTTP::cookie exists "warning"]} {
    HTTP::respond 200 content { 
    
        
            Warning
            
            
        
        

        
     } "Set-Cookie" "warning=1"
}

}

===================================== 2. redirect to another site with redirecting message

when HTTP_REQUEST {
if { [HTTP::host] equals "192.168.210.1" and [HTTP::uri] starts_with "/sasi" and ![HTTP::cookie exists "warning"]} {
set page "
The site  has been retired. 
After 5 seconds, you will automatically be redirected to our new page at "
HTTP::respond 200 content "${page}" Content-Type "text/html"
}}

1 Reply

  • Both iRules look like they have the same condition and similar outcomes; site no longer exists and then attempts to redirect. The first create a dialogue box via javascript, but doesn't look like it redirects to a different site just reloads the current page over and over. The second displays the message on the page and redirects automatically after 2 seconds using a meta refresh. These probably shouldn't be combined. You should decide which strategy to use and go with one of the two. However, below is a stab at combining the two if you really wanted to which creates a pop-up alert that when closed allows the meta refresh in the HTML to redirect.

    if { [HTTP::host] equals "192.168.210.1" and [HTTP::uri] starts_with "/sasi" and ![HTTP::cookie exists "warning"]} {
        HTTP::respond 200 content {
            
                
                    Warning
                    
                    
                
                
                    The site www.foods.com has been retired. 
                    After 5 seconds, you will automatically be redirected to our new page at www.drinks.com
                
             } "Set-Cookie" "warning=1"
        }
    }