mod_rewrite.h revision 2ae7ad6f58b7e3188ed4bd375a8930808529ba71
87ea898bcffe2ef490e833dc246a1cc0465d783fslive/* ====================================================================
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * The Apache Software License, Version 1.1
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * reserved.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * Redistribution and use in source and binary forms, with or without
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * modification, are permitted provided that the following conditions
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * 1. Redistributions of source code must retain the above copyright
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * notice, this list of conditions and the following disclaimer.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * 2. Redistributions in binary form must reproduce the above copyright
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * notice, this list of conditions and the following disclaimer in
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * the documentation and/or other materials provided with the
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * distribution.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * 3. The end-user documentation included with the redistribution,
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * if any, must include the following acknowledgment:
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * "This product includes software developed by the
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * Apache Software Foundation (http://www.apache.org/)."
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * Alternately, this acknowledgment may appear in the software itself,
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * if and wherever such third-party acknowledgments normally appear.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * 4. The names "Apache" and "Apache Software Foundation" must
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * not be used to endorse or promote products derived from this
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * software without prior written permission. For written
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * permission, please contact apache@apache.org.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * 5. Products derived from this software may not be called "Apache",
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * nor may "Apache" appear in their name, without prior written
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * permission of the Apache Software Foundation.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * SUCH DAMAGE.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * ====================================================================
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * This software consists of voluntary contributions made by many
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * individuals on behalf of the Apache Software Foundation. For more
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * information on the Apache Software Foundation, please see
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * Portions of this software are based upon public domain software
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * originally written at the National Center for Supercomputing Applications,
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * University of Illinois, Urbana-Champaign.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** _ __ ___ ___ __| | _ __ _____ ___ __(_) |_ ___
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** | '_ ` _ \ / _ \ / _` | | '__/ _ \ \ /\ / / '__| | __/ _ \
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** | | | | | | (_) | (_| | | | | __/\ V V /| | | | || __/
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___|
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** URL Rewriting Module
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** This module uses a rule-based rewriting engine (based on a
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** regular-expression parser) to rewrite requested URLs on the fly.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** It supports an unlimited number of additional rule conditions (which can
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** operate on a lot of variables, even on HTTP headers) for granular
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** matching and even external database lookups (either via plain text
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** tables, DBM hash files or even external processes) for advanced URL
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** substitution.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** It operates on the full URLs (including the PATH_INFO part) both in
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** per-server context (httpd.conf) and per-dir context (.htaccess) and even
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** can generate QUERY_STRING parts on result. The rewriting result finally
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** can lead to internal subprocessing, external request redirection or even
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** to internal proxy throughput.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** This module was originally written in April 1996 and
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** gifted exclusively to the The Apache Software Foundation in July 1997 by
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** Ralf S. Engelschall
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** rse@engelschall.com
87ea898bcffe2ef490e833dc246a1cc0465d783fslive /* Include from the underlaying Unix system ... */
87ea898bcffe2ef490e833dc246a1cc0465d783fslive /* Include from the Apache server ... */
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * The key in the r->notes apr_table_t wherein we store our accumulated
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * Vary values, and the one used for per-condition checks in a chain.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive /* The NDBM support:
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * We support only NDBM files.
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * But we have to stat the file for the mtime,
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * so we also need to know the file extension
87ea898bcffe2ef490e833dc246a1cc0465d783fslive#elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM))
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** Some defines
87ea898bcffe2ef490e833dc246a1cc0465d783fslive#define REWRITE_FORCED_MIMETYPE_NOTEVAR "rewrite-forced-mimetype"
87ea898bcffe2ef490e833dc246a1cc0465d783fslive** our private data structures we handle with
87ea898bcffe2ef490e833dc246a1cc0465d783fslive /* the list structures for holding the mapfile information
87ea898bcffe2ef490e833dc246a1cc0465d783fslive * and the rewrite rules
87ea898bcffe2ef490e833dc246a1cc0465d783fslivetypedef struct {
87ea898bcffe2ef490e833dc246a1cc0465d783fslive const char *datafile; /* filename for map data files */
87ea898bcffe2ef490e833dc246a1cc0465d783fslive const char *checkfile; /* filename to check for map existence */
87ea898bcffe2ef490e833dc246a1cc0465d783fslive apr_file_t *fpin; /* in file pointer for program maps */
87ea898bcffe2ef490e833dc246a1cc0465d783fslive apr_file_t *fpout; /* out file pointer for program maps */
87ea898bcffe2ef490e833dc246a1cc0465d783fslive apr_file_t *fperr; /* err file pointer for program maps */
87ea898bcffe2ef490e833dc246a1cc0465d783fslive char *(*func)(request_rec *, /* function pointer for internal maps */
87ea898bcffe2ef490e833dc246a1cc0465d783fslivetypedef struct {
87ea898bcffe2ef490e833dc246a1cc0465d783fslivetypedef struct {
87ea898bcffe2ef490e833dc246a1cc0465d783fslive apr_array_header_t *rewriteconds; /* the corresponding RewriteCond entries */
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);
#ifndef NO_DBM_REWRITEMAP
static void rewrite_rand_init(void);
static int rewrite_rand(int l, int h);
char *key);
const char *subst);