You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Kwan, Kenneth Y" <ke...@cwhkt.com> on 2000/08/15 04:35:23 UTC

How to make mod_rewrite works with Tomcat ?

I have gone through many docs in tomcat FAQ / user guide /etc, Apache web
config, JServ mailing list achieve, !K However, I still can’t make
“mod_rewrite” and “mod_jserv” (tomcat) work together. 

My target is to config Apache and Tomcat so that when users access
/protected/*.html, the accesses are verified by an authentication servlet
say / servlet/SnoopServlet. I have configured Apache Web server with the
rewrite rules below:

<Location /protected>
RewriteEngine on
RewriteRule     (.*)            /servlet/SnoopServlet?target=$1 [L]
</Location>

And I have moved “LoadModule jserv_module       libexec/mod_jserv.so”
before “LoadModule rewrite_module     libexec/mod_rewrite.so” and
“AddModule mod_jserv.c” before “AddModule mod_rewrite.c”

Here are the rewrite.log captured:

10.18.20.90 - - [15/Aug/2000:10:42:35 +0800]
[mysvr.netvigator.com/sid#80ad8f4][rid#80d703c/initial]
 (3) [per-dir /protected/] add path-info postfix: /protected ->
/protected/test.html
10.18.20.90 - - [15/Aug/2000:10:42:35 +0800]
[mysvr.netvigator.com/sid#80ad8f4][rid#80d703c/initial]
 (3) [per-dir /protected/] strip per-dir prefix: /protected/test.html ->
test.html
10.18.20.90 - - [15/Aug/2000:10:42:35 +0800]
[mysvr.netvigator.com/sid#80ad8f4][rid#80d703c/initial]
 (3) [per-dir /protected/] applying pattern '(.*)' to uri 'test.html'
10.18.20.90 - - [15/Aug/2000:10:42:35 +0800]
[mysvr.netvigator.com/sid#80ad8f4][rid#80d703c/initial]
 (2) [per-dir /protected/] rewrite test.html ->
/servlet/SnoopServlet?target=test.html
10.18.20.90 - - [15/Aug/2000:10:42:35 +0800]
[mysvr.netvigator.com/sid#80ad8f4][rid#80d703c/initial]
 (3) split uri=/servlet/SnoopServlet?target=test.html ->
uri=/servlet/SnoopServlet, args=target=test.html
10.18.20.90 - - [15/Aug/2000:10:42:35 +0800]
[mysvr.netvigator.com/sid#80ad8f4][rid#80d703c/initial]
(1)	[per-dir /protected/] internal redirect with /servlet/SnoopServlet
[INTERNAL REDIRECT]


If I directly access the server using
“http://!K./servlet/SnoopServlet?target=test.html, it works. 
Also, if I use “RewriteRule     (.*)
/servlet/SnoopServlet?target=$1 [R,L]”, it works. However, this uses
external redirect. 

Could somebody help

Kenneth