Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

Maintenance URL by iRule

is it enough for Maintenance URL from abc.com..?

when HTTP_REQUEST { HTTP::redirect "http://www.abc.com/maintenance.html" }

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

If you already have a maintenance.html page on the site, then I would use this

when HTTP_REDIRECT {
    if { not ([HTTP::uri] equals "/maintenance.html") } {
        HTTP::redirect "<a href="http://www.abc.com/maintenance.html">http://www.abc.com/maintenance.html</a>"
    }
}    

Otherwise, you would have an endless loop because it's not checking if you're already on that page.

If you want a iRule based maintenance page, the Codeshare page has some examples of that.

1
Comments on this Answer
Comment made 20-Dec-2014 by Michael Jenkins 4161
Sorry. Forgot that putting a url in the code section causes that weird link issue.
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Try this then. If you want to add more exceptions, just append them to the first set of URI checks (the - denotes an additional value is on the next line). The -glob allows the use of wildcards (the * character). So in this case, anything starting with /images/ will be caught in that condition.

when HTTP_REQUEST { 
    switch -glob [string tolower [HTTP::uri]] {
        "/maintenance.html" -
        "/images/*" {
            # Do nothing. These are exceptions
            return
        }
        default {
            HTTP::redirect "/maintenance.html"                 
        }
    } 
}
1
Comments on this Answer
Comment made 20-Dec-2014 by siyadh 148
it works....but still not loading .gif file. :(
0
Comment made 20-Dec-2014 by Michael Jenkins 4161
If you look at the network tab in the developer tools of whatever browser you're using (or something like Fiddler), does it show the images keep getting 302 responses?
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi Micheal,

Thank you..please find updated

when HTTP_REQUEST { if { not ([HTTP::uri] equals "/maintenance.html") } { HTTP::redirect "http://www.abc.com/maintenance.html" } }

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi Michael,

is it when HTTP_REDIRECT
or
when HTTP_REQUEST

Because "when HTTP_REDIRECT" is not accepting. and error as below

Exception caught in LocalLB::urn:iControl:LocalLB/Rule::create() Exception: Common::OperationFailed primary_error_code : 17236305 (0x01070151) secondary_error_code : 0 error_string : 01070151:3: Rule [/Common/Maintenance_iRule_4] error: /Common/Maintenance_iRule_4:1: error: [unknown event (HTTP_REDIRECT)][when HTTP_REDIRECT { if { not ([HTTP::uri] equals "/maintenance.html") } { HTTP::redirect "/maintenance.html" } }]

0
Comments on this Answer
Comment made 20-Dec-2014 by Michael Jenkins 4161
sorry. mistype... it's HTTP_REQUEST.
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Updated: The other option would just use the uri, which would look like this instead...

when HTTP_REDIRECT {
    if { not ([HTTP::uri] equals "/maintenance.html") } {
        HTTP::redirect "/maintenance.html"
    }
}    
0
Comments on this Answer
Comment made 20-Dec-2014 by siyadh 148
is it HTTP_REQUEST or HTTP_REDIRECT because HTTP_REDIRECT throwing error..
0
Comment made 20-Dec-2014 by Michael Jenkins 4161
Sorry. HTTP_REQUEST...
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

we have made the below iRule and it is working...but images are blocking. images are in /images/

can we exclude images by conditions...?

when HTTP_REDIRECT { if { not ([HTTP::uri] equals "/maintenance.html") } { HTTP::redirect "/maintenance.html" } }

0