httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_rewrite.c
Date Mon, 29 Mar 2004 21:34:19 GMT
nd          2004/03/29 13:34:19

  Modified:    .        CHANGES
               modules/mappers mod_rewrite.c
  Log:
  add support for rewrite rules in proxy containers
  
  PR: 27985
  
  Revision  Changes    Path
  1.1441    +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1440
  retrieving revision 1.1441
  diff -u -u -r1.1440 -r1.1441
  --- CHANGES	29 Mar 2004 02:56:21 -0000	1.1440
  +++ CHANGES	29 Mar 2004 21:34:19 -0000	1.1441
  @@ -2,6 +2,9 @@
   
     [Remove entries to the current 2.0 section below, when backported]
   
  +  *) mod_rewrite now officially supports RewriteRules in <Proxy> sections.
  +     PR 27985.  [André Malo]
  +
     *) mod_cgid: Don't allow Scriptsock to be specified inside VirtualHost;
        Don't place script socket inside default server root instead of
        actual server root.  PR 27886.  [Jeff Trawick]
  
  
  
  1.254     +24 -7     httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.253
  retrieving revision 1.254
  diff -u -u -r1.253 -r1.254
  --- mod_rewrite.c	9 Mar 2004 17:33:15 -0000	1.253
  +++ mod_rewrite.c	29 Mar 2004 21:34:19 -0000	1.254
  @@ -3590,12 +3590,19 @@
       int i, rc;
       char *newuri = NULL;
       request_rec *r = ctx->r;
  +    int is_proxyreq = 0;
   
       ctx->uri = r->filename;
   
       if (ctx->perdir) {
           apr_size_t dirlen = strlen(ctx->perdir);
   
  +        /*
  +         * Proxy request?
  +         */
  +        is_proxyreq = (   r->proxyreq && r->filename
  +                       && !strncmp(r->filename, "proxy:", 6));
  +
           /* Since we want to match against the (so called) full URL, we have
            * to re-add the PATH_INFO postfix
            */
  @@ -3608,7 +3615,7 @@
           /* Additionally we strip the physical path from the url to match
            * it independent from the underlaying filesystem.
            */
  -        if (strlen(ctx->uri) >= dirlen &&
  +        if (!is_proxyreq && strlen(ctx->uri) >= dirlen &&
               !strncmp(ctx->uri, ctx->perdir, dirlen)) {
   
               rewritelog((r, 3, ctx->perdir, "strip per-dir prefix: %s -> %s",
  @@ -3721,7 +3728,8 @@
        * (1) it's an absolute URL path and
        * (2) it's a full qualified URL
        */
  -    if (ctx->perdir && *r->filename != '/' && !is_absolute_uri(r->filename))
{
  +    if (   ctx->perdir && !is_proxyreq && *r->filename != '/'
  +        && !is_absolute_uri(r->filename)) {
           rewritelog((r, 3, ctx->perdir, "add per-dir prefix: %s -> %s%s",
                       r->filename, ctx->perdir, r->filename));
   
  @@ -4338,6 +4346,7 @@
       int rulestatus;
       int n;
       char *ofilename;
  +    int is_proxyreq;
   
       dconf = (rewrite_perdir_conf *)ap_get_module_config(r->per_dir_config,
                                                           &rewrite_module);
  @@ -4354,15 +4363,23 @@
       }
   
       /*
  +     * Proxy request?
  +     */
  +    is_proxyreq = (   r->proxyreq && r->filename
  +                   && !strncmp(r->filename, "proxy:", 6));
  +
  +    /*
        *  .htaccess file is called before really entering the directory, i.e.:
        *  URL: http://localhost/foo  and .htaccess is located in foo directory
        *  Ignore such attempts, since they may lead to undefined behaviour.
        */
  -    l = strlen(dconf->directory) - 1;
  -    if (r->filename && strlen(r->filename) == l &&
  -        (dconf->directory)[l] == '/' &&
  -        !strncmp(r->filename, dconf->directory, l)) {
  -        return DECLINED;
  +    if (!is_proxyreq) {
  +        l = strlen(dconf->directory) - 1;
  +        if (r->filename && strlen(r->filename) == l &&
  +            (dconf->directory)[l] == '/' &&
  +            !strncmp(r->filename, dconf->directory, l)) {
  +            return DECLINED;
  +        }
       }
   
       /*
  
  
  

Mime
View raw message