tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Lindy <...@touchmove.com>
Subject Re: Here we go again - mod_webapp and mod_rewrite
Date Sun, 11 Aug 2002 12:33:04 GMT
Brendan,

I had a similar experience back in April and solved it by hacking 
mod_webapp myself. I tried posting my problem to tomcat-dev only to be 
greeted with credulity as Tomcat takes the high road with respect to being 
a reference implementation and mod_rewrite lets you do things Sun's 
specification specifically prohibits. None-the-less, I am true believer in 
mod_rewrite and was un-willing to give it up, especially because there are 
things you just can't do without it.

Below is a listing of my hack to mod_webapp.c. It works fine on RH Linux 
6.2 and 7.2, but I have not tried it on Windows, so you're on your own as 
far as compiling it.

Hope this helps,
Dan


         /* Match an Apache request */
         static int wam_match(request_rec *r) {
             wa_virtualhost *host=NULL;
         //    wa_application *appl=NULL;
         //    wa_chain *elem=NULL;

             /* Paranoid check */
             if (!wam_initialized) return(DECLINED);

             /* Check if this host was recognized */
             host=ap_get_module_config(r->server->module_config,&webapp_module);
             if (host==NULL) return(DECLINED);

         //    /* Check if the uri is contained in one of our applications 
root path */
         //    elem=host->apps;
         //    while(elem!=NULL) {
         //        appl=(wa_application *)elem->curr;
         //        if (strncmp(appl->rpth,r->uri,strlen(appl->rpth))==0) break;
         //
         //        appl=NULL;
         //        elem=elem->next;
         //    }
         //    if (appl==NULL) return(DECLINED);

             /* The uri path is matched: set the handler and return */
             r->handler=ap_pstrdup(r->pool,"webapp-handler");

         //    /* Set the webapp request structure into Apache's request 
structure */
         //    ap_set_module_config(r->request_config, &webapp_module, appl);
         //    return(OK);
             return(DECLINED);  // added

         }

         /* Handle the current request */
         static int wam_invoke(request_rec *r) {
             server_rec *svr=r->server;
             conn_rec *con=r->connection;
             wa_virtualhost *host=NULL;   // added
             wa_application *appl=NULL;
             wa_chain *elem=NULL;         // added
             wa_request *req=NULL;
             const char *msg=NULL;
             char *stmp=NULL;
             char *ctmp=NULL;
             char *ssl_temp;
             int ret=0;

             /* Paranoid check */
             if (!wam_initialized) return(DECLINED);

         // begin added...

             /* Check if this host was recognized */
             host=ap_get_module_config(r->server->module_config,&webapp_module);
             if (host==NULL) return(DECLINED);

             /* Check if the uri is contained in one of our applications 
root path */
             elem=host->apps;
             while(elem!=NULL) {
                 appl=(wa_application *)elem->curr;
                 if (strncmp(appl->rpth,r->uri,strlen(appl->rpth))==0) break;

                 appl=NULL;
                 elem=elem->next;
             }
             if (appl==NULL) return(DECLINED);

             /* Set the webapp request structure into Apache's request 
structure */
             ap_set_module_config(r->request_config, &webapp_module, appl);

         // ...end added



At 10:46 AM 8/7/02 -0400, Brendan Benke wrote:
>i originally posted this to tomcat-users, but i think it might be better
>served here.
>
>i know this topic is old and has been discussed at length before, i'm still
>having trouble finding an elegant solution.  i used to use apache with
>mod_jserv and some simple url rewriting.   moving to tomcat, i have
>encountered problems with mod_webapp and mod_rewrite.  specifically, the
>original URI being rewritten instead of just passed through.
>
>for example:  (these are nested inside VirtualHost tags)
>
>==================
>     ApJServMount /servlets ajpv12://localhost:8007/root
>
><IfModule mod_rewrite.c>
>        RewriteEngine on
>        RewriteCond %{REQUEST_URI} !^/ir/images
>        RewriteCond %{REQUEST_URI} !^/ir/html
>        RewriteCond %{REQUEST_URI} !^/ir/applets
>        RewriteCond %{REQUEST_URI} !^/ir/dtds
>        RewriteCond %{REQUEST_URI} !^/index.html
>        RewriteRule ^/.*  /servlets/RequestHandler [PT]
></IfModule>
>
>==================
>
>used to work with ApacheJServ and  ApacheModuleRewrite.dll while
>
>==================
>  WebAppConnection warpConnection warp localhost:8008
>
><IfModule mod_rewrite.c>
>        RewriteEngine on
>        RewriteCond %{REQUEST_URI} !^/ir/images
>        RewriteCond %{REQUEST_URI} !^/ir/html
>        RewriteCond %{REQUEST_URI} !^/ir/applets
>        RewriteCond %{REQUEST_URI} !^/ir/dtds
>        RewriteCond %{REQUEST_URI} !^/index.html
>        RewriteRule ^/.*  /site/servlet/RequestHandler [PT]
></IfModule>
>
>   WebAppDeploy site warpConnection /site
>==================
>doesn't work at all.  using the [R] flag does sucessfully redirect the
>rewritten request, but the new URI is used instead of the old, as was the
>behavior under JServ.
>
>can anyone point me in the right direction here?  i've seen home-brew
>patches to various connection handlers that see to fudge the behavior i'm
>looking for, but certainly there must be something i'm missing.
>
>i'm using:
>tomcat 4.0.4
>apache 1.3.26
>windows 2000
>
>any help much appreciated!!!!
>
>brendan
>
>
>
>--
>To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message