Forum Discussion
Aug 20, 2009
The "HTTP::uri" is a command with muliple purposes. If you don't supply a parameter, it retrieves the value. If you give it a uri, then it will set the value. You need to remove your "set" command like this:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/config"} {
HTTP::uri /main
}
}
This code will keep the URI intact in the clients browser but change it before it gets to the server.
If you want the browser to stay the same (ie /config) then you should be alls et.
If you want to change the browser, then there's a problem with this approach. The URI is part of the request, not the response. The browser displays the URI that was sent to the server in the initial request. If you want to change the browser, then you'll want to issue a redirect to the client. This will essentially tell the client (browser) to issue a new request to the updated URI.
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/config" } {
HTTP::redirect "http://[HTTP::host]/main"
}
}
So, hopefully that answers your questions. One last thing to keep in mind is that you are replacing "ALL" requests that start with "/config" to a URI of "/main". So http://server/config1234, http://server/config/a/b, etc. will all map to http://server/main. If you want to retain the original portion of the URI past the "/config" value, then you'll want to do some string replacement (look at the "string map" TCL command for an easy way to do it).
Hope this helps...
-Joe