Jérémie Barthés wrote:
...
Make a file rewrite.config in conf/Catalina/localhost/ that contains :
RewriteRule ^/mypath/(.*)$ /examples/jsp/$1
copy the line
<Valve
className="org.apache.catalina.valves.rewrite.RewriteValve" />
in the conf/server.xml file, line 131
Since this is a Valve, it will run before Tomcat attempts to match the URL to an actual
directory or webapp.
try the followings URLs :
1) http://localhost:8080/mypath/async
This matches the rewrite rule, so it will be rewritten to URL
/examples/jsp/async
Then Tomcat will attempt to match this to a directory or webapp, and find that
(catalina_base)/webapps/examples/jsp/async is a directory.
It will thus respond to the browser with a 302 re-direct to
http://localhost:8080/examples/jsp/async/
which is actually the "correct" URL.
And this is what will be shown in the browser URL bar. This, in my view, is expected
behaviour. The server does that, so that when an actual response is generated (for the
correct URL http://localhost:8080/examples/jsp/async/), the browser can cache this
response under the correct URL.
Then the browser re-issues a request for
http://localhost:8080/examples/jsp/async/
and that is when Tomcat will actually generate a "real" response, because this time it is
a correct URL. So the response appears to the browser, as coming from
http://localhost:8080/examples/jsp/async/
which is correct.
2) http://localhost:8080/mypath/async/
This also matches the rewrite rule, so it gets rewritten to
http://localhost:8080/examples/jsp/async/
which is a correct URL.
Thus Tomcat will immediately generate a real response (without an intermediate 302
redirect), which will be appear in the browser URL bar as a response to
http://localhost:8080/mypath/async/
This is also expected behaviour.
I believe that if you do not want to see the first redirect URL
http://localhost:8080/examples/jsp/async/
in the browser, you have to modify your rewrite rules, perhaps by using a RewriteCond with
the -d flag, to check first if the URL points to an existing directory, and if yes add the
terminating "/" yourself (with a RewriteRule) before other rewrite tests/rules take place.
But I personally think that there is no need for a patch here.
the result i have is :
http://localhost:8080/mypath/async =>
http://localhost:8080/examples/jsp/async/ (visible rewrite)
no, it is the *redirect* which is visible, after the rewrite (to
http://localhost:8080/examples/jsp/async) has taken place and Tomcat finds that this is a
directory.
http://localhost:8080/mypath/async/ => http://localhost:8080/mypath/async/
no redirect, so the browser doesn't know, and believes that the response has actually come
from the URL http://localhost:8080/mypath/async/.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org