redirects with WS7.0
I'm trying to do two redirects that seem like they should be pretty simple. I would be happy to use the new <If> functionality in WS7.0.
I want to redirect all requests using http to use https instead.
I want to redirect all requests to the top level (http://myserver.com or https://myserver.com) to a specific URL (/app). So requests redirect as follows
FROM http://myserver.com TO https://myserver.com/app
FROM https://myserver.com TO https://myserver.com/app
FROM http://myserver.com/info TO https://myserver.com/info
Seems simple, but I can't quite get it.
Thanks.
[625 byte] By [
esb2000a] at [2007-11-27 5:50:23]

# 2
Thanks for the quick reply, and for providing helpful detail.
I think that is very close. The first case is quite clear. The second case, I don't want to just redirect the /info URL, I want all URLs on this server to be redirected. I was unclear, I meant the /info just as an example.
Every http URL should be redirected to its https counterpart.
Thanks again.
# 3
You can redirect all URIs to a an SSL-enabled server:<If not $security>
NameTrans fn="redirect" url-prefix="https://example.com"
</If>You could also use the <canonical-server-name> element in server.xml. With a <canonical-server-name> of https://example.com, the server will redirect all requests that don't use SSL or the example.com domain name in the URL.
# 5
An update:
I tried various combinations of the following:
<If $uri = '/'>
NameTrans fn="redirect" url="https://myserver.com/app>"
</If>
<ElseIf not $security>
NameTrans fn="redirect" url-prefix="https://myserver.com>"
</If>
This did not work correctly for all use cases. There seemed to be problems when I surfed to http://myserver.com/app. I would have expected the second redirect to apply, but it did not. This only was the case when "app" was the URI for a web application, everything was fine for regular document directories.
I used the first rule for mapping '/' to "/app", and I replaced the second rule with a canonical-server-name in server.xml, as recommended, and this worked great.
Thanks again for the advice.
# 7
I had moved on, and it took a bit of time to get back to testing this, but I wanted to follow up.My directives followed the ntrans-j2ee redirect, but once I moved them up it worked as desired. So both alternatives work, the redirect or the use of a canonical server name.