Forum Discussion
Chris_Wentland2
May 01, 2006Nimbostratus
Hey,
I noticed that you are re-writing your URI on every request to force the client into a particular directory structure. Here is a snippet of cleaned up code that may be more efficient for you than rewriting every request.
Basically, you look for the URL and matching application dir in the URI. If it matches, it goes to the pool. Otherwise, you get redirected to the original URL/Application DIR. This way, you are not rewriting every request, and clients cannot look outside of your web directory.
when HTTP_REQUEST {
if { [HTTP::host] equals "www1.test.com" and [HTTP::uri] starts_with "/www1/"} {
pool www1
} elseif { [HTTP::host] equals "www2.test.com" and [HTTP::uri] starts_with "/www2/"} {
pool www2
} elseif { [HTTP::host] equals "www1.test.com"} {
HTTP::redirect "http://[HTTP::host]/www1/"
} elseif { [HTTP::host] equals "www2.test.com"} {
HTTP::redirect "http://[HTTP::host]/www2/"
} else {
drop
}
}
Thanks and good luck!