Forum Discussion
iFile maintenance page issue with longer paths
Hi all,
We are using ifiles to serve static maintenance page for our web services. Everything works fine when user navigates to "domain.com/", but if the path contains second "/" (domain.com/abc/) then ifile image won't load.
when HTTP_REQUEST {
if {([active_members Pool-X]) < 1} {
switch [string tolower [HTTP::uri]] {
"/image.png" {
HTTP::respond 200 content [ifile get "image.png"] "Content-Type" "image/png"
}
default {
HTTP::respond 200 content [ifile get "maintenance_page"] "Content-Type" "text/html" connection close
event disable
}
}
}
}
What should I do to make this irule work with any path?
Thanks,
Jani
Hi Jani,
I stringly recommend you to not use a 200OK for every response send to your site. It will pretty much hurt your existing SEO ratings...
Its far more elegant to tell your clients (and also search engines) that the site is currently not available by 407 - Temporary Redirect to a given Maintenante-Page which is then served using a 503 - Service Unavailable status code.
when HTTP_REQUEST { if { [active_members Pool-X] < 1 } then { switch -exact -- [HTTP::uri] { "/image.png" { HTTP::respond 503 content [ifile get "image.png"] "Content-Type" "image/png" } "/maintenance.html" { HTTP::respond 503 content [ifile get "maintenance_page"] "Content-Type" "text/html" } default { HTTP::respond 407 Location "/maintenance.html" } } } }
Note: For further information how to handle Maintenance Pages the right way, please check out https://plus.google.com/+PierreFar/posts/Gas8vjZ5fmB
Note: To make the image load in your current iRule example, you may review your HTML and make sure the image file is referenced via "/image.png" (absolute to root web) instead of using just "image.png" (relative to the current web folder). I'm pretty much sure this would fix your original iRule and problem...
Cheers, Kai
- MiguelNimbostratus
Just add extra path to the ifile location, one will work on the main page and the other on the path, enter like this:
- when HTTP_REQUEST {
- if {([active_members Pool-X]) < 1} {
- switch [string tolower [HTTP::uri]] {
- "/image.png" {
- HTTP::respond 200 content [ifile get "image.png"] "Content-Type" "image/png"
- }
- "/abc/image.png" {
- HTTP::respond 200 content [ifile get "image.png"] "Content-Type" "image/png"
- }
- default {
- HTTP::respond 200 content [ifile get "maintenance_page"] "Content-Type" "text/html" connection close
- event disable
- }
- }
- }
- }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com