Andrzej, the HTTP::path command will change the URL as it's passed back to the backend app server. It doesn't issue a "redirect" back to the client so the browser will still show the original url but the web logs in the backend will show the newly updated value.
If you want the browser to be reflected with the change, you'll want to use "HTTP::redirect" to send a 302 redirect (or HTTP::respond for a 301) to the browser to tell it to issue a new request to the changed URL. Then the browser address bar will be correct with what the backend server receives.
There are reasons for both commands so it really depends on what you want want the user experience to be.
In your example, if the url doesn't start with "/app1/", then it prepends "/apps/" to the URL. it's not "appending" as you note int he comment Here are some examples
Browser -> Server
http://and.rew.com/app1/ (HTTP::path = /app1/) -> http://and.rew.com/app1/
http://and.rew.com/ (HTTP::path = /) -> http://and.rew.com/apps//
http://and.rew.com/foo (HTTP::path = /foo) -> http://and.rew.com/apps//foo
http://and.rew.com/foo/bar (HTTP::path = /foo/bar) -> http://and.rew.com/apps//foo/bar
Since HTTP::path will already be prefixed with a "/" and you are prefixing with "/apps/" that has a trailing slash, there will be 2 slashes which probably isn't what you want.
Back to your original question, I'm a little confused. You said for all URLs that are not the root "/", nothing is done but for the root "/" you get redirected to "/apps/". But, your iRule only checks for "/app1/" and modifies all other URLs. In the end of your question you also appended "url" to "/apps/". But in that case, url is only "/".
Per your original question, I'd code the iRule something like this:
when HTTP_REQUEST {
if { HTTP::path eq "/" } {
HTTP::path "/apps/"
or issue a redirect
HTTP::redirect "/apps/"
}
}
If this doesn't get what you want, if you can provide a "before" and "after" url mapping with several examples, that will help with narrowing down the logic.
-Joe