Forum Discussion
hooleylist
Oct 24, 2008Cirrostratus
Hi there,
The rule looks okay. You could potentially eliminate the need for the -regex flag in the switch statements by using two cases for each URI. The glob flag enables string wildcards. I'm not sure whether you're trying to match /feed and /feed/ exactly or whether you want to match /feed*. Here is an example.
Also, when the pool has no active members, if you rewrite every URI to /index.html, any objects (like stylesheets or images) will also be rewritten and the page won't be rendered correctly. The simplest fix for this might be to move the index and other files to a separate maintenance directory which isn't used anywhere else in the application. You could then only rewrite the URI if the URI doesn't contain that maintenance directory name.
We discussed this in a recent post:
Using LB_FAILED and change the URI w/o 302 (Click here)
Aaron
when HTTP_REQUEST {
if { [active_members [LB::server pool]] == 0}{
if {not ([HTTP::path] starts_with "/maintenance_files/"} {
HTTP::uri "/maintenance_files/index.html"
}
pool dmz-stage2
}
I shall be the new uber global redirector
switch -glob [HTTP::uri] {
"/gift*" -
"/gift/*" {
set id ""
let's get the last numeric element of the uri
regexp {\d+$} [HTTP::path] id
this if is probably not needed anymore seeing as how we hardcode id
if { $id ne "" } {
are we special email or feeds...
switch [HTTP::path] {
"/feed" -
"/feed/" {
HTTP::uri "/gift/index.php?gg_id=$id&sec=feed&[HTTP::query]"
}
"/email" 0
"/email" {
HTTP::uri "/gift/index.php?gg_id=$id&sec=email&[HTTP::query]"
}
default {
HTTP::uri "/gift/index.php?gg_id=$id&[HTTP::query]"
}
}
}
use pool dmz-stage;
}
default {
pool dmz-stage;
}
}
}