Forum Discussion

FMA's avatar
FMA
Icon for Nimbostratus rankNimbostratus
Nov 10, 2016

Old story - maintenance page iRule

Hello,

I know this topic has been discussed many times already but there is one thing I got stuck with - is it possible to combine two of these actions into a single iRule? :

when HTTP_REQUEST {
      HTTP::respond 200 content {
      
      The site has been moved
      
      The webiste has moved to https://aaa.aaa
      Please update your bookmarks.
      
      
   } 
}

and this:

HTTP::respond 200 content [ifile get we_have_moved] "Content-Type" "image/gif" }

The idea is to have a tiny HTML page with ifile inserted image.

Thanks and appologies for my possible WEB-ignorance.

4 Replies

  • I think this thread may help you.

     

    irule-maintanance-page-with-ifile

     

    Basically, you set up an iRule with a default action that posts your HTML, with the contexts above for the subsequent content calls for the iFiles.

     

    Hope it helps!

     

  • FMA's avatar
    FMA
    Icon for Nimbostratus rankNimbostratus

    Thanks David! It really helped me to get into this. Just one more thing here - I'm trying to use a variable below (REDIRECTURL) to simplify future modifications, but when I try to use it within HTTP:respond code it doesn't return variable value and just prints it as a text "$REDIRECTURL".

     

    when HTTP_REQUEST {
    set REDIRECTURL "https://example.com"
    switch [HTTP::uri] {
        "/we_have_moved.png" {
            HTTP::respond 200 content [ifile get we_have_moved.png] "Content-Type" "image/gif"
        }
        default {
            HTTP::respond 200 content {
                
                The site has been moved
                
                The webiste has moved to 
                Please update your bookmarks!
                You will be redirected in
                50 seconds 
                ![HTML5 Icon](we_have_moved.png)
                
                
                
                }
            }
        }
    }

    Is there any way to make this work?

     

    Thanks!

     

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    Try this then:

    when HTTP_REQUEST {
        set REDIRECTURL "https://example.com"
        set message "
                The site has been moved
                
                The webiste has moved to 
                Please update your bookmarks!
                You will be redirected in
                50 seconds 
                !\[HTML5 Icon\](we_have_moved.png)
                
                
                "
    
        switch [HTTP::uri] {
            "/we_have_moved.png" {
                HTTP::respond 200 content [ifile get we_have_moved.png] "Content-Type" "image/gif"
            }
            default {
                HTTP::respond 200 content $message
            }
        }
    }
    
  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    Or:

    when HTTP_REQUEST {
        set REDIRECTURL "https://example.com"
        switch [HTTP::uri] {
            "/we_have_moved.png" {
                HTTP::respond 200 content [ifile get we_have_moved.png] "Content-Type" "image/gif"
            }
            default {
                HTTP::respond 200 content "\
                The site has been moved\
                
                The webiste has moved to \
                Please update your bookmarks!\
                You will be redirected in\
                50 seconds \
                ![HTML5 Icon](we_have_moved.png)\
                \
                \
                "
            }
        }
    }