I'm afraid I overlooked the requirement for the handling of the home page. Here's the updated rule:
Permanently redirect HTTP to HTTPS
Redirect requests for the home page to /foo/ (retaining query string if present)
when HTTP_REQUEST {
if { [HTTP::path] eq "/" || [string tolower [HTTP::path]] eq "/index.php" } {
HTTP::respond 301 Location "https://[HTTP::host]/foo[HTTP::uri]"
} else
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
}
}
You'll want to make sure
index.php
is replaced with the proper default page name for the home page.
However, is there a good reason to redirect the home page? Wouldn't it be better to keep the URL for the root the same while serving
/foo/
?
By the way, crodriguez's solution is also worth considering, although I'm personally a bit hesitant about the increased complexity that's introduced with you deploy an LTP (mainly because it tends to become harder to troubleshoot).