mod_rewrite.h revision 0bbb249eafe9ef9508821f0ef58e7440625ecd62
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive/* ====================================================================
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * The Apache Software License, Version 1.1
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * reserved.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * Redistribution and use in source and binary forms, with or without
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * modification, are permitted provided that the following conditions
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * 1. Redistributions of source code must retain the above copyright
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * notice, this list of conditions and the following disclaimer.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * 2. Redistributions in binary form must reproduce the above copyright
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * notice, this list of conditions and the following disclaimer in
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * the documentation and/or other materials provided with the
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * distribution.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * 3. The end-user documentation included with the redistribution,
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * if any, must include the following acknowledgment:
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * "This product includes software developed by the
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * Apache Software Foundation (http://www.apache.org/)."
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * Alternately, this acknowledgment may appear in the software itself,
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * if and wherever such third-party acknowledgments normally appear.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * 4. The names "Apache" and "Apache Software Foundation" must
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * not be used to endorse or promote products derived from this
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * software without prior written permission. For written
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * permission, please contact apache@apache.org.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * 5. Products derived from this software may not be called "Apache",
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * nor may "Apache" appear in their name, without prior written
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * permission of the Apache Software Foundation.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * SUCH DAMAGE.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * ====================================================================
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * This software consists of voluntary contributions made by many
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * individuals on behalf of the Apache Software Foundation. For more
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * information on the Apache Software Foundation, please see
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * Portions of this software are based upon public domain software
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * originally written at the National Center for Supercomputing Applications,
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * University of Illinois, Urbana-Champaign.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** _ __ ___ ___ __| | _ __ _____ ___ __(_) |_ ___
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** | '_ ` _ \ / _ \ / _` | | '__/ _ \ \ /\ / / '__| | __/ _ \
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** | | | | | | (_) | (_| | | | | __/\ V V /| | | | || __/
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___|
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** URL Rewriting Module
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** This module uses a rule-based rewriting engine (based on a
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** regular-expression parser) to rewrite requested URLs on the fly.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** It supports an unlimited number of additional rule conditions (which can
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** operate on a lot of variables, even on HTTP headers) for granular
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** matching and even external database lookups (either via plain text
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** tables, DBM hash files or even external processes) for advanced URL
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** substitution.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** It operates on the full URLs (including the PATH_INFO part) both in
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** per-server context (httpd.conf) and per-dir context (.htaccess) and even
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** can generate QUERY_STRING parts on result. The rewriting result finally
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** can lead to internal subprocessing, external request redirection or even
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** to internal proxy throughput.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** This module was originally written in April 1996 and
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** gifted exclusively to the The Apache Software Foundation in July 1997 by
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** Ralf S. Engelschall
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** rse@engelschall.com
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive /* Include from the underlaying Unix system ... */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive /* Include from the Apache server ... */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * The key in the r->notes apr_table_t wherein we store our accumulated
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * Vary values, and the one used for per-condition checks in a chain.
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** Some defines
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive#define REWRITE_FORCED_MIMETYPE_NOTEVAR "rewrite-forced-mimetype"
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive/*** max cookie size in rfc 2109 ***/
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive** our private data structures we handle with
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive /* the list structures for holding the mapfile information
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * and the rewrite rules
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslivetypedef struct {
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive const char *datafile; /* filename for map data files */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive const char *dbmtype; /* dbm type for dbm map data files */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive const char *checkfile; /* filename to check for map existence */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive apr_file_t *fpin; /* in file pointer for program maps */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive apr_file_t *fpout; /* out file pointer for program maps */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive apr_file_t *fperr; /* err file pointer for program maps */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive char *(*func)(request_rec *, /* function pointer for internal maps */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslivetypedef struct {
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslivetypedef struct {
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive apr_array_header_t *rewriteconds; /* the corresponding RewriteCond entries */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive char *forced_mimetype; /* forced MIME type of substitution */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive int forced_responsecode; /* forced HTTP redirect response status */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive char *env[MAX_ENV_FLAGS+1]; /* added environment variables */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive /* the per-server or per-virtual-server configuration
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * statically generated once on startup for every server
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslivetypedef struct {
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive const char *rewritelogfile; /* the RewriteLog filename */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive apr_file_t *rewritelogfp; /* the RewriteLog open filepointer */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive int rewriteloglevel; /* the RewriteLog level of verbosity */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive apr_array_header_t *rewritemaps; /* the RewriteMap entries */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive apr_array_header_t *rewriteconds; /* the RewriteCond entries (temporary) */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive apr_array_header_t *rewriterules; /* the RewriteRule entries */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive server_rec *server; /* the corresponding server indicator */
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive /* the per-directory configuration
3fa58e00171aebf3b2cfa90035ed530f5b1f651dslive * generated on-the-fly by Apache server for current request
typedef struct cacheentry {
char *key;
char *value;
} cacheentry;
typedef struct tlbentry {
int t[CACHE_TLB_COLS];
typedef struct cachelist {
char *resource;
} cachelist;
typedef struct cache {
#if APR_HAS_THREADS
} cache;
typedef struct backrefinfo {
char *source;
int nsub;
} backrefinfo;
void *dconf,
const char *option);
const char *name);
const char *a1);
const char *str);
char *str);
const char *str);
char *str);
server_rec *s);
char *perdir);
char *perdir);
static void rewrite_rand_init(void);
static int rewrite_rand(int l, int h);
char *key);
const char *subst);