⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_rewrite.h

📁 Apache HTTP Server 是一个功能强大的灵活的与HTTP/1.1相兼容的web服务器.这里给出的是Apache HTTP服务器的源码。
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as * applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */#ifndef MOD_REWRITE_H#define MOD_REWRITE_H 1/***                       _                            _ _**   _ __ ___   ___   __| |    _ __ _____      ___ __(_) |_ ___**  | '_ ` _ \ / _ \ / _` |   | '__/ _ \ \ /\ / / '__| | __/ _ \**  | | | | | | (_) | (_| |   | | |  __/\ V  V /| |  | | ||  __/**  |_| |_| |_|\___/ \__,_|___|_|  \___| \_/\_/ |_|  |_|\__\___|**                       |_____|****  URL Rewriting Module****  This module uses a rule-based rewriting engine (based on a**  regular-expression parser) to rewrite requested URLs on the fly.****  It supports an unlimited number of additional rule conditions (which can**  operate on a lot of variables, even on HTTP headers) for granular**  matching and even external database lookups (either via plain text**  tables, DBM hash files or even external processes) for advanced URL**  substitution.****  It operates on the full URLs (including the PATH_INFO part) both in**  per-server context (httpd.conf) and per-dir context (.htaccess) and even**  can generate QUERY_STRING parts on result.   The rewriting result finally**  can lead to internal subprocessing, external request redirection or even**  to internal proxy throughput.****  This module was originally written in April 1996 and**  gifted exclusively to the The Apache Software Foundation in July 1997 by****      Ralf S. Engelschall**      rse@engelschall.com**      www.engelschall.com*/#include "apr.h"#define APR_WANT_STRFUNC#define APR_WANT_MEMFUNC#include "apr_want.h"    /* Include from the underlaying Unix system ... */#if APR_HAVE_STDARG_H#include <stdarg.h>#endif#if APR_HAVE_STDLIB_H#include <stdlib.h>#endif#if APR_HAVE_CTYPE_H#include <ctype.h>#endif#if APR_HAVE_SYS_TYPES_H#include <sys/types.h>#endif#if APR_HAS_THREADS#include "apr_thread_mutex.h"#endif#include "apr_optional.h"#include "apr_dbm.h"#include "ap_config.h"    /* Include from the Apache server ... */#define CORE_PRIVATE#include "httpd.h"#include "http_config.h"#include "http_request.h"#include "http_core.h"#include "http_log.h"#include "http_vhost.h"    /*     * The key in the r->notes apr_table_t wherein we store our accumulated     * Vary values, and the one used for per-condition checks in a chain.     */#define VARY_KEY "rewrite-Vary"#define VARY_KEY_THIS "rewrite-Vary-this"/*****  Some defines***/#define ENVVAR_SCRIPT_URL "SCRIPT_URL"#define ENVVAR_SCRIPT_URI "SCRIPT_URI"#define REWRITE_FORCED_MIMETYPE_NOTEVAR "rewrite-forced-mimetype"#define CONDFLAG_NONE               1<<0#define CONDFLAG_NOCASE             1<<1#define CONDFLAG_NOTMATCH           1<<2#define CONDFLAG_ORNEXT             1<<3#define RULEFLAG_NONE               1<<0#define RULEFLAG_FORCEREDIRECT      1<<1#define RULEFLAG_LASTRULE           1<<2#define RULEFLAG_NEWROUND           1<<3#define RULEFLAG_CHAIN              1<<4#define RULEFLAG_IGNOREONSUBREQ     1<<5#define RULEFLAG_NOTMATCH           1<<6#define RULEFLAG_PROXY              1<<7#define RULEFLAG_PASSTHROUGH        1<<8#define RULEFLAG_FORBIDDEN          1<<9#define RULEFLAG_GONE               1<<10#define RULEFLAG_QSAPPEND           1<<11#define RULEFLAG_NOCASE             1<<12#define RULEFLAG_NOESCAPE           1<<13#define ACTION_NORMAL               1<<0#define ACTION_NOESCAPE             1<<1#define MAPTYPE_TXT                 1<<0#define MAPTYPE_DBM                 1<<1#define MAPTYPE_PRG                 1<<2#define MAPTYPE_INT                 1<<3#define MAPTYPE_RND                 1<<4#define ENGINE_DISABLED             1<<0#define ENGINE_ENABLED              1<<1#define OPTION_NONE                 1<<0#define OPTION_INHERIT              1<<1#define CACHEMODE_TS                1<<0#define CACHEMODE_TTL               1<<1#define CACHE_TLB_ROWS 1024#define CACHE_TLB_COLS 4#ifndef FALSE#define FALSE 0#define TRUE  !FALSE#endif#ifndef NO#define NO    FALSE#define YES   TRUE#endif#ifndef RAND_MAX#define RAND_MAX 32767#endif#ifndef LONG_STRING_LEN#define LONG_STRING_LEN 2048#endif#define MAX_ENV_FLAGS 15#define MAX_COOKIE_FLAGS 15/*** max cookie size in rfc 2109 ***/#define MAX_COOKIE_LEN 4096/* default maximum number of internal redirects */#define REWRITE_REDIRECT_LIMIT 10/*****  our private data structures we handle with***/    /* the list structures for holding the mapfile information     * and the rewrite rules     */typedef struct {    const char *name;              /* the name of the map */    const char *datafile;          /* filename for map data files */    const char *dbmtype;           /* dbm type for dbm map data files */    const char *checkfile;         /* filename to check for map existence */    int   type;                    /* the type of the map */    apr_file_t *fpin;              /* in  file pointer for program maps */    apr_file_t *fpout;             /* out file pointer for program maps */    apr_file_t *fperr;             /* err file pointer for program maps */    char *(*func)(request_rec *,   /* function pointer for internal maps */                  char *);    char **argv;    char *cachename;               /* name for the cache */} rewritemap_entry;typedef struct {    char    *input;                /* Input string of RewriteCond */    char    *pattern;              /* the RegExp pattern string */    regex_t *regexp;    int      flags;                /* Flags which control the match */} rewritecond_entry;typedef struct {    apr_array_header_t *rewriteconds;    /* the corresponding RewriteCond entries */    char    *pattern;              /* the RegExp pattern string */    regex_t *regexp;               /* the RegExp pattern compilation */    char    *output;               /* the Substitution string */    int      flags;                /* Flags which control the substitution */    char    *forced_mimetype;      /* forced MIME type of substitution */    int      forced_responsecode;  /* forced HTTP redirect response status */    char    *env[MAX_ENV_FLAGS+1]; /* added environment variables */    char    *cookie[MAX_COOKIE_FLAGS+1]; /* added cookies */    int      skip;                 /* number of next rules to skip */} rewriterule_entry;    /* the per-server or per-virtual-server configuration     * statically generated once on startup for every server     */typedef struct {    int           state;           /* the RewriteEngine state */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -