Hi Chris,
I think one issue is that you're using local variables in HTTP_REQUEST when setting the maint_prefix string (set maint_prefix "/maintenancepage"), but referencing a global variable (if {$uri equals ${::maint_prefix}}...) in the rest of the rule. Try changing the global variables to locals and see if you get better results. The Codeshare example declares the maint_prefix and maint_len variables in the RULE_INIT event. So they're implicitly defined as globals, even though they don't use the double colon in the name: 'set ::global_var value'.
If you make that change and it still doesn't work, can you log the output of [lindex $::maint_index_html 0]? Do you get the correct HTML string? If not, can you post what you see? Can you run 'b class main_index_html list' and post the output?
There are some other fixes/optimizations you could make to the example. You could save a few steps by using string map to trim off the maint_prefix. So instead of:
set maint_prefix "/maintenancepage"
set maint_len [string length $maint_prefix]
set uri [HTTP::uri]
...
set uri [string range $uri $::maint_len end]
to:
set maint_prefix "/maintenancepage"
set uri [HTTP::uri]
...
set uri [string map [list $maint_prefix ""] $uri]
Also, the redirect location should be an absolute URL (
https://www.example.com/redirect_location.html) not just the path (/redirect_location.html):
ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt
14.30 Location
The Location response-header field is used to redirect the recipient
to a location other than the Request-URI for completion of the
request or identification of a new resource. For 201 (Created)
responses, the Location is that of the new resource which was created
by the request. For 3xx responses, the location SHOULD indicate the
server's preferred URI for automatic redirection to the resource.
The
field value consists of a single absolute URI.
Location = "Location" ":" absoluteURI
An example is:
Location:
http://www.w3.org/pub/WWW/People.html
Aaron