----------
From: Steve Snodgrass ssnodgra@fore.com
To: Java Apache Users java-apache-users@list.working-dogs.com
Subject: Using mod_rewrite to map arbitrary URLs to servlets
Date: Thu, Apr 29, 1999, 1:58 PM
On Wed, Apr 28, 1999 at 11:44:33PM +0200, Jean-Luc Rochat wrote:
> use mod_rewrite for this one.
Thanks very much, mod_rewrite turned out to be the ticket for this problem.
I thought I'd summarize the solution to my problem to the list since someone
else may run into this. Basically, this is a general way to map *any* URL to
a java servlet, including URLs in directories that you are already serving
HTML files out of. This assumes that you have a zone set up to run servlets
under the /servlets URL.
First, you must have the mod_rewrite module, and the JServ module must come
*before* mod_rewrite in the AddModule list. In other words:
AddModule mod_jserv.c
AddModule mod_rewrite.c
Then, you set up rewrite rules like this:
RewriteEngine on
RewriteRule ^/mantix/mxbooker$ /servlets/com.mx.webtime.servlets.MxBooker [PT]
RewriteRule ^/mantix/mxclerk$ /servlets/com.mx.webtime.servlets.MxClerk [PT]
Result:
URL /mantix/mxbooker runs servlet com.mx.webtime.servlets.MxBooker
URL /mantix/mxclerk runs servlet com.mx.webtime.servlets.MxClerk
The key is using the [PT] flag (passthrough) with mod_rewrite, or else the
URLs will try to refer to files, which of course don't exist. |