mod_alias.c revision b4c8a80f7dbfc9b56dbe03bdc28f0b5eb5f23697
/* ====================================================================
* Copyright (c) 1995-1999 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* 4. The names "Apache Server" and "Apache Group" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Group and was originally based
* on public domain software written at the National Center for
* Supercomputing Applications, University of Illinois, Urbana-Champaign.
* For more information on the Apache Group and the Apache HTTP server
* project, please see <http://www.apache.org/>.
*
*/
/*
* http_alias.c: Stuff for dealing with directory aliases
*
* Original by Rob McCool, rewritten in succession by David Robinson
* and rst.
*
*/
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
typedef struct {
char *real;
char *fake;
char *handler;
int redir_status; /* 301, 302, 303, 410, etc */
} alias_entry;
typedef struct {
typedef struct {
{
alias_server_conf *a =
return a;
}
static void *create_alias_dir_config(ap_context_t *p, char *d)
{
alias_dir_conf *a =
return a;
}
{
alias_server_conf *a =
alias_server_conf *base = (alias_server_conf *) basev, *overrides = (alias_server_conf *) overridesv;
return a;
}
{
alias_dir_conf *a =
return a;
}
int use_regex)
{
/* XX r can NOT be relative to DocumentRoot here... compat bug. */
if (use_regex) {
return "Regular expression could not be compiled.";
}
return NULL;
}
{
}
{
}
int use_regex)
{
char *f = arg2;
else if (ap_isdigit(*arg1))
else {
f = arg1;
}
if (use_regex) {
if (r == NULL)
return "Regular expression could not be compiled.";
}
if (ap_is_HTTP_REDIRECT(status)) {
if (!url)
return "URL to redirect to is missing";
return "Redirect to non-URL";
}
else {
if (url)
return "Redirect URL not valid for this status";
}
else
return NULL;
}
{
}
{
}
static const command_rec alias_cmds[] =
{
"a fakename and a realname"},
"a fakename and a realname"},
"an optional status, then document to be redirected and destination URL"},
"a regular expression and a filename"},
"a regular expression and a filename"},
"an optional status, then a regular expression and destination URL"},
"a document to be redirected, then the destination URL"},
"a document to be redirected, then the destination URL"},
{NULL}
};
{
while (aliasp < end_fakename) {
if (*aliasp == '/') {
/* any number of '/' in the alias matches any number in
* the supplied URI, but there must be at least one...
*/
if (*urip != '/')
return 0;
while (*aliasp == '/')
++aliasp;
while (*urip == '/')
++urip;
}
else {
/* Other characters are compared literally */
return 0;
}
}
/* Check last alias path component matched all the way */
return 0;
/* Return number of characters from URI which matched (may be
* greater than length of alias, since we may have matched
* doubled slashes)
*/
}
{
int i;
alias_entry *p = &entries[i];
int l;
if (p->regexp) {
if (p->real) {
}
}
else {
/* need something non-null */
}
}
}
else {
if (l > 0) {
if (doesc) {
char *escurl;
}
else
}
}
if (found) {
if (p->handler) { /* Set handler, and leave a note for mod_cgi */
}
*status = p->redir_status;
return found;
}
}
return NULL;
}
static int translate_alias_redir(request_rec *r)
{
char *ret;
int status;
return DECLINED;
if (ap_is_HTTP_REDIRECT(status)) {
/* include QUERY_STRING if any */
if (r->args) {
}
}
return status;
}
return OK;
}
return DECLINED;
}
static int fixup_redir(request_rec *r)
{
void *dconf = r->per_dir_config;
char *ret;
int status;
/* It may have changed since last time, so try again */
if (ap_is_HTTP_REDIRECT(status))
return status;
}
return DECLINED;
}
static void register_hooks(void)
{
}
{
create_alias_dir_config, /* dir config creater */
merge_alias_dir_config, /* dir merger --- default is to override */
create_alias_config, /* server config */
merge_alias_config, /* merge server configs */
alias_cmds, /* command ap_table_t */
NULL, /* handlers */
register_hooks /* register hooks */
};