|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/*
|
|
Packit |
90a5c9 |
* http_alias.c: Stuff for dealing with directory aliases
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Original by Rob McCool, rewritten in succession by David Robinson
|
|
Packit |
90a5c9 |
* and rst.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "apr_strings.h"
|
|
Packit |
90a5c9 |
#include "apr_lib.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define APR_WANT_STRFUNC
|
|
Packit |
90a5c9 |
#include "apr_want.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "ap_config.h"
|
|
Packit |
90a5c9 |
#include "httpd.h"
|
|
Packit |
90a5c9 |
#include "http_core.h"
|
|
Packit |
90a5c9 |
#include "http_config.h"
|
|
Packit |
90a5c9 |
#include "http_request.h"
|
|
Packit |
90a5c9 |
#include "http_log.h"
|
|
Packit |
90a5c9 |
#include "ap_expr.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct {
|
|
Packit |
90a5c9 |
const char *real;
|
|
Packit |
90a5c9 |
const char *fake;
|
|
Packit |
90a5c9 |
char *handler;
|
|
Packit |
90a5c9 |
ap_regex_t *regexp;
|
|
Packit |
90a5c9 |
int redir_status; /* 301, 302, 303, 410, etc */
|
|
Packit |
90a5c9 |
} alias_entry;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct {
|
|
Packit |
90a5c9 |
apr_array_header_t *aliases;
|
|
Packit |
90a5c9 |
apr_array_header_t *redirects;
|
|
Packit |
90a5c9 |
} alias_server_conf;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct {
|
|
Packit |
90a5c9 |
unsigned int alias_set:1;
|
|
Packit |
90a5c9 |
unsigned int redirect_set:1;
|
|
Packit |
90a5c9 |
apr_array_header_t *redirects;
|
|
Packit |
90a5c9 |
const ap_expr_info_t *alias;
|
|
Packit |
90a5c9 |
char *handler;
|
|
Packit |
90a5c9 |
const ap_expr_info_t *redirect;
|
|
Packit |
90a5c9 |
int redirect_status; /* 301, 302, 303, 410, etc */
|
|
Packit |
90a5c9 |
} alias_dir_conf;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
module AP_MODULE_DECLARE_DATA alias_module;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static char magic_error_value;
|
|
Packit |
90a5c9 |
#define PREGSUB_ERROR (&magic_error_value)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void *create_alias_config(apr_pool_t *p, server_rec *s)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
alias_server_conf *a =
|
|
Packit |
90a5c9 |
(alias_server_conf *) apr_pcalloc(p, sizeof(alias_server_conf));
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
a->aliases = apr_array_make(p, 20, sizeof(alias_entry));
|
|
Packit |
90a5c9 |
a->redirects = apr_array_make(p, 20, sizeof(alias_entry));
|
|
Packit |
90a5c9 |
return a;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void *create_alias_dir_config(apr_pool_t *p, char *d)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
alias_dir_conf *a =
|
|
Packit |
90a5c9 |
(alias_dir_conf *) apr_pcalloc(p, sizeof(alias_dir_conf));
|
|
Packit |
90a5c9 |
a->redirects = apr_array_make(p, 2, sizeof(alias_entry));
|
|
Packit |
90a5c9 |
return a;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void *merge_alias_config(apr_pool_t *p, void *basev, void *overridesv)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
alias_server_conf *a =
|
|
Packit |
90a5c9 |
(alias_server_conf *) apr_pcalloc(p, sizeof(alias_server_conf));
|
|
Packit |
90a5c9 |
alias_server_conf *base = (alias_server_conf *) basev;
|
|
Packit |
90a5c9 |
alias_server_conf *overrides = (alias_server_conf *) overridesv;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
a->aliases = apr_array_append(p, overrides->aliases, base->aliases);
|
|
Packit |
90a5c9 |
a->redirects = apr_array_append(p, overrides->redirects, base->redirects);
|
|
Packit |
90a5c9 |
return a;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void *merge_alias_dir_config(apr_pool_t *p, void *basev, void *overridesv)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
alias_dir_conf *a =
|
|
Packit |
90a5c9 |
(alias_dir_conf *) apr_pcalloc(p, sizeof(alias_dir_conf));
|
|
Packit |
90a5c9 |
alias_dir_conf *base = (alias_dir_conf *) basev;
|
|
Packit |
90a5c9 |
alias_dir_conf *overrides = (alias_dir_conf *) overridesv;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
a->redirects = apr_array_append(p, overrides->redirects, base->redirects);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
a->alias = (overrides->alias_set == 0) ? base->alias : overrides->alias;
|
|
Packit |
90a5c9 |
a->handler = (overrides->alias_set == 0) ? base->handler : overrides->handler;
|
|
Packit |
90a5c9 |
a->alias_set = overrides->alias_set || base->alias_set;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
a->redirect = (overrides->redirect_set == 0) ? base->redirect : overrides->redirect;
|
|
Packit |
90a5c9 |
a->redirect_status = (overrides->redirect_set == 0) ? base->redirect_status : overrides->redirect_status;
|
|
Packit |
90a5c9 |
a->redirect_set = overrides->redirect_set || base->redirect_set;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return a;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* need prototype for overlap check */
|
|
Packit |
90a5c9 |
static int alias_matches(const char *uri, const char *alias_fakename);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *add_alias_internal(cmd_parms *cmd, void *dummy,
|
|
Packit |
90a5c9 |
const char *fake, const char *real,
|
|
Packit |
90a5c9 |
int use_regex)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
server_rec *s = cmd->server;
|
|
Packit |
90a5c9 |
alias_server_conf *conf = ap_get_module_config(s->module_config,
|
|
Packit |
90a5c9 |
&alias_module);
|
|
Packit |
90a5c9 |
alias_entry *new = apr_array_push(conf->aliases);
|
|
Packit |
90a5c9 |
alias_entry *entries = (alias_entry *)conf->aliases->elts;
|
|
Packit |
90a5c9 |
int i;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* XXX: real can NOT be relative to DocumentRoot here... compat bug. */
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (err != NULL) {
|
|
Packit |
90a5c9 |
return err;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (use_regex) {
|
|
Packit |
90a5c9 |
new->regexp = ap_pregcomp(cmd->pool, fake, AP_REG_EXTENDED);
|
|
Packit |
90a5c9 |
if (new->regexp == NULL)
|
|
Packit |
90a5c9 |
return "Regular expression could not be compiled.";
|
|
Packit |
90a5c9 |
new->real = real;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
/* XXX This may be optimized, but we must know that new->real
|
|
Packit |
90a5c9 |
* exists. If so, we can dir merge later, trusing new->real
|
|
Packit |
90a5c9 |
* and just canonicalizing the remainder. Not till I finish
|
|
Packit |
90a5c9 |
* cleaning out the old ap_canonical stuff first.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
new->real = real;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
new->fake = fake;
|
|
Packit |
90a5c9 |
new->handler = cmd->info;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* check for overlapping (Script)Alias directives
|
|
Packit |
90a5c9 |
* and throw a warning if found one
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (!use_regex) {
|
|
Packit |
90a5c9 |
for (i = 0; i < conf->aliases->nelts - 1; ++i) {
|
|
Packit |
90a5c9 |
alias_entry *alias = &entries[i];
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ( (!alias->regexp && alias_matches(fake, alias->fake) > 0)
|
|
Packit |
90a5c9 |
|| (alias->regexp && !ap_regexec(alias->regexp, fake, 0, NULL, 0))) {
|
|
Packit |
90a5c9 |
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server, APLOGNO(00671)
|
|
Packit |
90a5c9 |
"The %s directive in %s at line %d will probably "
|
|
Packit |
90a5c9 |
"never match because it overlaps an earlier "
|
|
Packit |
90a5c9 |
"%sAlias%s.",
|
|
Packit |
90a5c9 |
cmd->cmd->name, cmd->directive->filename,
|
|
Packit |
90a5c9 |
cmd->directive->line_num,
|
|
Packit |
90a5c9 |
alias->handler ? "Script" : "",
|
|
Packit |
90a5c9 |
alias->regexp ? "Match" : "");
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
break; /* one warning per alias should be sufficient */
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *add_alias(cmd_parms *cmd, void *dummy, const char *fake,
|
|
Packit |
90a5c9 |
const char *real)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
if (real) {
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return add_alias_internal(cmd, dummy, fake, real, 0);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
alias_dir_conf *dirconf = (alias_dir_conf *) dummy;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIRECTORY|NOT_IN_FILES);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (err != NULL) {
|
|
Packit |
90a5c9 |
return err;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!cmd->path) {
|
|
Packit |
90a5c9 |
return "Alias must have two arguments when used globally";
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
dirconf->alias =
|
|
Packit |
90a5c9 |
ap_expr_parse_cmd(cmd, fake, AP_EXPR_FLAG_STRING_RESULT,
|
|
Packit |
90a5c9 |
&err, NULL);
|
|
Packit |
90a5c9 |
if (err) {
|
|
Packit |
90a5c9 |
return apr_pstrcat(cmd->temp_pool,
|
|
Packit |
90a5c9 |
"Cannot parse alias expression '", fake, "': ", err,
|
|
Packit |
90a5c9 |
NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
dirconf->handler = cmd->info;
|
|
Packit |
90a5c9 |
dirconf->alias_set = 1;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *add_alias_regex(cmd_parms *cmd, void *dummy,
|
|
Packit |
90a5c9 |
const char *fake, const char *real)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return add_alias_internal(cmd, dummy, fake, real, 1);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *add_redirect_internal(cmd_parms *cmd,
|
|
Packit |
90a5c9 |
alias_dir_conf *dirconf,
|
|
Packit |
90a5c9 |
const char *arg1, const char *arg2,
|
|
Packit |
90a5c9 |
const char *arg3, int use_regex)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
alias_entry *new;
|
|
Packit |
90a5c9 |
server_rec *s = cmd->server;
|
|
Packit |
90a5c9 |
alias_server_conf *serverconf = ap_get_module_config(s->module_config,
|
|
Packit |
90a5c9 |
&alias_module);
|
|
Packit |
90a5c9 |
int status = (int) (long) cmd->info;
|
|
Packit |
90a5c9 |
int grokarg1 = 1;
|
|
Packit |
90a5c9 |
ap_regex_t *regex = NULL;
|
|
Packit |
90a5c9 |
const char *fake = arg2;
|
|
Packit |
90a5c9 |
const char *url = arg3;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/*
|
|
Packit |
90a5c9 |
* Logic flow:
|
|
Packit |
90a5c9 |
* Go ahead and try to grok the 1st arg, in case it is a
|
|
Packit |
90a5c9 |
* Redirect status. Now if we have 3 args, we expect that
|
|
Packit |
90a5c9 |
* we were able to understand that 1st argument (it's something
|
|
Packit |
90a5c9 |
* we expected, so if not, then we bail
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (!strcasecmp(arg1, "permanent"))
|
|
Packit |
90a5c9 |
status = HTTP_MOVED_PERMANENTLY;
|
|
Packit |
90a5c9 |
else if (!strcasecmp(arg1, "temp"))
|
|
Packit |
90a5c9 |
status = HTTP_MOVED_TEMPORARILY;
|
|
Packit |
90a5c9 |
else if (!strcasecmp(arg1, "seeother"))
|
|
Packit |
90a5c9 |
status = HTTP_SEE_OTHER;
|
|
Packit |
90a5c9 |
else if (!strcasecmp(arg1, "gone")) {
|
|
Packit |
90a5c9 |
status = HTTP_GONE;
|
|
Packit |
90a5c9 |
grokarg1 = -1;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else if (apr_isdigit(*arg1)) {
|
|
Packit |
90a5c9 |
status = atoi(arg1);
|
|
Packit |
90a5c9 |
if (!ap_is_HTTP_REDIRECT(status)) {
|
|
Packit |
90a5c9 |
grokarg1 = -1;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
grokarg1 = 0;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (arg3 && !grokarg1)
|
|
Packit |
90a5c9 |
return "Redirect: invalid first argument (of three)";
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/*
|
|
Packit |
90a5c9 |
* if we have the 2nd arg and we understand the 1st one as a redirect
|
|
Packit |
90a5c9 |
* status (3xx, but not things like 404 /robots.txt), or if we have the
|
|
Packit |
90a5c9 |
* 1st arg but don't understand it, we use the expression syntax assuming
|
|
Packit |
90a5c9 |
* a path from the location.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* if we understand the first arg but have no second arg, we are dealing
|
|
Packit |
90a5c9 |
* with a status like "GONE" or a non-redirect status (e.g. 404, 503).
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (!cmd->path) {
|
|
Packit |
90a5c9 |
/* <Location> context only for now */
|
|
Packit |
90a5c9 |
;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else if ((grokarg1 > 0 && arg2 && !arg3) || (!grokarg1 && !arg2)) {
|
|
Packit |
90a5c9 |
const char *expr_err = NULL;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
url = grokarg1 ? arg2 : arg1;
|
|
Packit |
90a5c9 |
dirconf->redirect =
|
|
Packit |
90a5c9 |
ap_expr_parse_cmd(cmd, url, AP_EXPR_FLAG_STRING_RESULT,
|
|
Packit |
90a5c9 |
&expr_err, NULL);
|
|
Packit |
90a5c9 |
if (expr_err) {
|
|
Packit |
90a5c9 |
return apr_pstrcat(cmd->temp_pool,
|
|
Packit |
90a5c9 |
"Cannot parse redirect expression '", url, "': ", expr_err,
|
|
Packit |
90a5c9 |
NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
dirconf->redirect_status = status;
|
|
Packit |
90a5c9 |
dirconf->redirect_set = 1;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else if (grokarg1 < 0 && !arg2) {
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
dirconf->redirect_status = status;
|
|
Packit |
90a5c9 |
dirconf->redirect_set = 1;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/*
|
|
Packit |
90a5c9 |
* if we don't have the 3rd arg and we didn't understand the 1st
|
|
Packit |
90a5c9 |
* one, then assume URL-path URL. This also handles case, eg, GONE
|
|
Packit |
90a5c9 |
* we even though we don't have a 3rd arg, we did understand the 1st
|
|
Packit |
90a5c9 |
* one, so we don't want to re-arrange
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (!arg3 && !grokarg1) {
|
|
Packit |
90a5c9 |
fake = arg1;
|
|
Packit |
90a5c9 |
url = arg2;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (use_regex) {
|
|
Packit |
90a5c9 |
regex = ap_pregcomp(cmd->pool, fake, AP_REG_EXTENDED);
|
|
Packit |
90a5c9 |
if (regex == NULL)
|
|
Packit |
90a5c9 |
return "Regular expression could not be compiled.";
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (ap_is_HTTP_REDIRECT(status)) {
|
|
Packit |
90a5c9 |
if (!url)
|
|
Packit |
90a5c9 |
return "URL to redirect to is missing";
|
|
Packit |
90a5c9 |
/* PR#35314: we can allow path components here;
|
|
Packit |
90a5c9 |
* they get correctly resolved to full URLs.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (!use_regex && !ap_is_url(url) && (url[0] != '/'))
|
|
Packit |
90a5c9 |
return "Redirect to non-URL";
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
if (url)
|
|
Packit |
90a5c9 |
return "Redirect URL not valid for this status";
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (cmd->path)
|
|
Packit |
90a5c9 |
new = apr_array_push(dirconf->redirects);
|
|
Packit |
90a5c9 |
else
|
|
Packit |
90a5c9 |
new = apr_array_push(serverconf->redirects);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
new->fake = fake;
|
|
Packit |
90a5c9 |
new->real = url;
|
|
Packit |
90a5c9 |
new->regexp = regex;
|
|
Packit |
90a5c9 |
new->redir_status = status;
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *add_redirect(cmd_parms *cmd, void *dirconf,
|
|
Packit |
90a5c9 |
const char *arg1, const char *arg2,
|
|
Packit |
90a5c9 |
const char *arg3)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return add_redirect_internal(cmd, dirconf, arg1, arg2, arg3, 0);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *add_redirect2(cmd_parms *cmd, void *dirconf,
|
|
Packit |
90a5c9 |
const char *arg1, const char *arg2)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return add_redirect_internal(cmd, dirconf, arg1, arg2, NULL, 0);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *add_redirect_regex(cmd_parms *cmd, void *dirconf,
|
|
Packit |
90a5c9 |
const char *arg1, const char *arg2,
|
|
Packit |
90a5c9 |
const char *arg3)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return add_redirect_internal(cmd, dirconf, arg1, arg2, arg3, 1);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const command_rec alias_cmds[] =
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
AP_INIT_TAKE12("Alias", add_alias, NULL, RSRC_CONF | ACCESS_CONF,
|
|
Packit |
90a5c9 |
"a fakename and a realname, or a realname in a Location"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE12("ScriptAlias", add_alias, "cgi-script", RSRC_CONF | ACCESS_CONF,
|
|
Packit |
90a5c9 |
"a fakename and a realname, or a realname in a Location"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE123("Redirect", add_redirect, (void *) HTTP_MOVED_TEMPORARILY,
|
|
Packit |
90a5c9 |
OR_FILEINFO,
|
|
Packit |
90a5c9 |
"an optional status, then document to be redirected and "
|
|
Packit |
90a5c9 |
"destination URL"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE2("AliasMatch", add_alias_regex, NULL, RSRC_CONF,
|
|
Packit |
90a5c9 |
"a regular expression and a filename"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE2("ScriptAliasMatch", add_alias_regex, "cgi-script", RSRC_CONF,
|
|
Packit |
90a5c9 |
"a regular expression and a filename"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE23("RedirectMatch", add_redirect_regex,
|
|
Packit |
90a5c9 |
(void *) HTTP_MOVED_TEMPORARILY, OR_FILEINFO,
|
|
Packit |
90a5c9 |
"an optional status, then a regular expression and "
|
|
Packit |
90a5c9 |
"destination URL"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE2("RedirectTemp", add_redirect2,
|
|
Packit |
90a5c9 |
(void *) HTTP_MOVED_TEMPORARILY, OR_FILEINFO,
|
|
Packit |
90a5c9 |
"a document to be redirected, then the destination URL"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE2("RedirectPermanent", add_redirect2,
|
|
Packit |
90a5c9 |
(void *) HTTP_MOVED_PERMANENTLY, OR_FILEINFO,
|
|
Packit |
90a5c9 |
"a document to be redirected, then the destination URL"),
|
|
Packit |
90a5c9 |
{NULL}
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static int alias_matches(const char *uri, const char *alias_fakename)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
const char *aliasp = alias_fakename, *urip = uri;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
while (*aliasp) {
|
|
Packit |
90a5c9 |
if (*aliasp == '/') {
|
|
Packit |
90a5c9 |
/* any number of '/' in the alias matches any number in
|
|
Packit |
90a5c9 |
* the supplied URI, but there must be at least one...
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (*urip != '/')
|
|
Packit |
90a5c9 |
return 0;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
do {
|
|
Packit |
90a5c9 |
++aliasp;
|
|
Packit |
90a5c9 |
} while (*aliasp == '/');
|
|
Packit |
90a5c9 |
do {
|
|
Packit |
90a5c9 |
++urip;
|
|
Packit |
90a5c9 |
} while (*urip == '/');
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
/* Other characters are compared literally */
|
|
Packit |
90a5c9 |
if (*urip++ != *aliasp++)
|
|
Packit |
90a5c9 |
return 0;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Check last alias path component matched all the way */
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (aliasp[-1] != '/' && *urip != '\0' && *urip != '/')
|
|
Packit |
90a5c9 |
return 0;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Return number of characters from URI which matched (may be
|
|
Packit |
90a5c9 |
* greater than length of alias, since we may have matched
|
|
Packit |
90a5c9 |
* doubled slashes)
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return urip - uri;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static char *try_alias(request_rec *r)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
alias_dir_conf *dirconf =
|
|
Packit |
90a5c9 |
(alias_dir_conf *) ap_get_module_config(r->per_dir_config, &alias_module);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (dirconf->alias) {
|
|
Packit |
90a5c9 |
const char *err = NULL;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
char *found = apr_pstrdup(r->pool,
|
|
Packit |
90a5c9 |
ap_expr_str_exec(r, dirconf->alias, &err));
|
|
Packit |
90a5c9 |
if (err) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02825)
|
|
Packit |
90a5c9 |
"Can't evaluate alias expression: %s", err);
|
|
Packit |
90a5c9 |
return PREGSUB_ERROR;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (dirconf->handler) { /* Set handler, and leave a note for mod_cgi */
|
|
Packit |
90a5c9 |
r->handler = dirconf->handler;
|
|
Packit |
90a5c9 |
apr_table_setn(r->notes, "alias-forced-type", r->handler);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
/* XXX This is as SLOW as can be, next step, we optimize
|
|
Packit |
90a5c9 |
* and merge to whatever part of the found path was already
|
|
Packit |
90a5c9 |
* canonicalized. After I finish eliminating os canonical.
|
|
Packit |
90a5c9 |
* Better fail test for ap_server_root_relative needed here.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
found = ap_server_root_relative(r->pool, found);
|
|
Packit |
90a5c9 |
return found;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static char *try_redirect(request_rec *r, int *status)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
alias_dir_conf *dirconf =
|
|
Packit |
90a5c9 |
(alias_dir_conf *) ap_get_module_config(r->per_dir_config, &alias_module);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (dirconf->redirect_set) {
|
|
Packit |
90a5c9 |
apr_uri_t uri;
|
|
Packit |
90a5c9 |
const char *err = NULL;
|
|
Packit |
90a5c9 |
char *found = "";
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (dirconf->redirect) {
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
found = apr_pstrdup(r->pool,
|
|
Packit |
90a5c9 |
ap_expr_str_exec(r, dirconf->redirect, &err));
|
|
Packit |
90a5c9 |
if (err) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02826)
|
|
Packit |
90a5c9 |
"Can't evaluate redirect expression: %s", err);
|
|
Packit |
90a5c9 |
return PREGSUB_ERROR;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_uri_parse(r->pool, found, &uri);
|
|
Packit |
90a5c9 |
/* Do not escape the query string or fragment. */
|
|
Packit |
90a5c9 |
found = apr_uri_unparse(r->pool, &uri, APR_URI_UNP_OMITQUERY);
|
|
Packit |
90a5c9 |
found = ap_escape_uri(r->pool, found);
|
|
Packit |
90a5c9 |
if (uri.query) {
|
|
Packit |
90a5c9 |
found = apr_pstrcat(r->pool, found, "?", uri.query, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (uri.fragment) {
|
|
Packit |
90a5c9 |
found = apr_pstrcat(r->pool, found, "#", uri.fragment, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
*status = dirconf->redirect_status;
|
|
Packit |
90a5c9 |
return found;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static char *try_alias_list(request_rec *r, apr_array_header_t *aliases,
|
|
Packit |
90a5c9 |
int is_redir, int *status)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
alias_entry *entries = (alias_entry *) aliases->elts;
|
|
Packit |
90a5c9 |
ap_regmatch_t regm[AP_MAX_REG_MATCH];
|
|
Packit |
90a5c9 |
char *found = NULL;
|
|
Packit |
90a5c9 |
int i;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
for (i = 0; i < aliases->nelts; ++i) {
|
|
Packit |
90a5c9 |
alias_entry *alias = &entries[i];
|
|
Packit |
90a5c9 |
int l;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (alias->regexp) {
|
|
Packit |
90a5c9 |
if (!ap_regexec(alias->regexp, r->uri, AP_MAX_REG_MATCH, regm, 0)) {
|
|
Packit |
90a5c9 |
if (alias->real) {
|
|
Packit |
90a5c9 |
found = ap_pregsub(r->pool, alias->real, r->uri,
|
|
Packit |
90a5c9 |
AP_MAX_REG_MATCH, regm);
|
|
Packit |
90a5c9 |
if (found) {
|
|
Packit |
90a5c9 |
if (is_redir) {
|
|
Packit |
90a5c9 |
apr_uri_t uri;
|
|
Packit |
90a5c9 |
apr_uri_parse(r->pool, found, &uri);
|
|
Packit |
90a5c9 |
/* Do not escape the query string or fragment. */
|
|
Packit |
90a5c9 |
found = apr_uri_unparse(r->pool, &uri,
|
|
Packit |
90a5c9 |
APR_URI_UNP_OMITQUERY);
|
|
Packit |
90a5c9 |
found = ap_escape_uri(r->pool, found);
|
|
Packit |
90a5c9 |
if (uri.query) {
|
|
Packit |
90a5c9 |
found = apr_pstrcat(r->pool, found, "?",
|
|
Packit |
90a5c9 |
uri.query, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (uri.fragment) {
|
|
Packit |
90a5c9 |
found = apr_pstrcat(r->pool, found, "#",
|
|
Packit |
90a5c9 |
uri.fragment, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00672)
|
|
Packit |
90a5c9 |
"Regex substitution in '%s' failed. "
|
|
Packit |
90a5c9 |
"Replacement too long?", alias->real);
|
|
Packit |
90a5c9 |
return PREGSUB_ERROR;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
/* need something non-null */
|
|
Packit |
90a5c9 |
found = "";
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
l = alias_matches(r->uri, alias->fake);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (l > 0) {
|
|
Packit |
90a5c9 |
ap_set_context_info(r, alias->fake, alias->real);
|
|
Packit |
90a5c9 |
if (is_redir) {
|
|
Packit |
90a5c9 |
char *escurl;
|
|
Packit |
90a5c9 |
escurl = ap_os_escape_path(r->pool, r->uri + l, 1);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
found = apr_pstrcat(r->pool, alias->real, escurl, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else
|
|
Packit |
90a5c9 |
found = apr_pstrcat(r->pool, alias->real, r->uri + l, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (found) {
|
|
Packit |
90a5c9 |
if (alias->handler) { /* Set handler, and leave a note for mod_cgi */
|
|
Packit |
90a5c9 |
r->handler = alias->handler;
|
|
Packit |
90a5c9 |
apr_table_setn(r->notes, "alias-forced-type", r->handler);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
/* XXX This is as SLOW as can be, next step, we optimize
|
|
Packit |
90a5c9 |
* and merge to whatever part of the found path was already
|
|
Packit |
90a5c9 |
* canonicalized. After I finish eliminating os canonical.
|
|
Packit |
90a5c9 |
* Better fail test for ap_server_root_relative needed here.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (!is_redir) {
|
|
Packit |
90a5c9 |
found = ap_server_root_relative(r->pool, found);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (found) {
|
|
Packit |
90a5c9 |
*status = alias->redir_status;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return found;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static int translate_alias_redir(request_rec *r)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
ap_conf_vector_t *sconf = r->server->module_config;
|
|
Packit |
90a5c9 |
alias_server_conf *serverconf = ap_get_module_config(sconf, &alias_module);
|
|
Packit |
90a5c9 |
char *ret;
|
|
Packit |
90a5c9 |
int status;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (r->uri[0] != '/' && r->uri[0] != '\0') {
|
|
Packit |
90a5c9 |
return DECLINED;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ((ret = try_redirect(r, &status)) != NULL
|
|
Packit |
90a5c9 |
|| (ret = try_alias_list(r, serverconf->redirects, 1, &status))
|
|
Packit |
90a5c9 |
!= NULL) {
|
|
Packit |
90a5c9 |
if (ret == PREGSUB_ERROR)
|
|
Packit |
90a5c9 |
return HTTP_INTERNAL_SERVER_ERROR;
|
|
Packit |
90a5c9 |
if (ap_is_HTTP_REDIRECT(status)) {
|
|
Packit |
90a5c9 |
if (ret[0] == '/') {
|
|
Packit |
90a5c9 |
char *orig_target = ret;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ret = ap_construct_url(r->pool, ret, r);
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00673)
|
|
Packit |
90a5c9 |
"incomplete redirection target of '%s' for "
|
|
Packit |
90a5c9 |
"URI '%s' modified to '%s'",
|
|
Packit |
90a5c9 |
orig_target, r->uri, ret);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (!ap_is_url(ret)) {
|
|
Packit |
90a5c9 |
status = HTTP_INTERNAL_SERVER_ERROR;
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00674)
|
|
Packit |
90a5c9 |
"cannot redirect '%s' to '%s'; "
|
|
Packit |
90a5c9 |
"target is not a valid absoluteURI or abs_path",
|
|
Packit |
90a5c9 |
r->uri, ret);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
/* append requested query only, if the config didn't
|
|
Packit |
90a5c9 |
* supply its own.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (r->args && !ap_strchr(ret, '?')) {
|
|
Packit |
90a5c9 |
ret = apr_pstrcat(r->pool, ret, "?", r->args, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
apr_table_setn(r->headers_out, "Location", ret);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return status;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ((ret = try_alias(r)) != NULL
|
|
Packit |
90a5c9 |
|| (ret = try_alias_list(r, serverconf->aliases, 0, &status))
|
|
Packit |
90a5c9 |
!= NULL) {
|
|
Packit |
90a5c9 |
r->filename = ret;
|
|
Packit |
90a5c9 |
return OK;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return DECLINED;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static int fixup_redir(request_rec *r)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
void *dconf = r->per_dir_config;
|
|
Packit |
90a5c9 |
alias_dir_conf *dirconf =
|
|
Packit |
90a5c9 |
(alias_dir_conf *) ap_get_module_config(dconf, &alias_module);
|
|
Packit |
90a5c9 |
char *ret;
|
|
Packit |
90a5c9 |
int status;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* It may have changed since last time, so try again */
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ((ret = try_redirect(r, &status)) != NULL
|
|
Packit |
90a5c9 |
|| (ret = try_alias_list(r, dirconf->redirects, 1, &status))
|
|
Packit |
90a5c9 |
!= NULL) {
|
|
Packit |
90a5c9 |
if (ret == PREGSUB_ERROR)
|
|
Packit |
90a5c9 |
return HTTP_INTERNAL_SERVER_ERROR;
|
|
Packit |
90a5c9 |
if (ap_is_HTTP_REDIRECT(status)) {
|
|
Packit |
90a5c9 |
if (ret[0] == '/') {
|
|
Packit |
90a5c9 |
char *orig_target = ret;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ret = ap_construct_url(r->pool, ret, r);
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00675)
|
|
Packit |
90a5c9 |
"incomplete redirection target of '%s' for "
|
|
Packit |
90a5c9 |
"URI '%s' modified to '%s'",
|
|
Packit |
90a5c9 |
orig_target, r->uri, ret);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (!ap_is_url(ret)) {
|
|
Packit |
90a5c9 |
status = HTTP_INTERNAL_SERVER_ERROR;
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00676)
|
|
Packit |
90a5c9 |
"cannot redirect '%s' to '%s'; "
|
|
Packit |
90a5c9 |
"target is not a valid absoluteURI or abs_path",
|
|
Packit |
90a5c9 |
r->uri, ret);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
/* append requested query only, if the config didn't
|
|
Packit |
90a5c9 |
* supply its own.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (r->args && !ap_strchr(ret, '?')) {
|
|
Packit |
90a5c9 |
ret = apr_pstrcat(r->pool, ret, "?", r->args, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
apr_table_setn(r->headers_out, "Location", ret);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return status;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return DECLINED;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void register_hooks(apr_pool_t *p)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
static const char * const aszSucc[]={ "mod_userdir.c",
|
|
Packit |
90a5c9 |
"mod_vhost_alias.c",NULL };
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ap_hook_translate_name(translate_alias_redir,NULL,aszSucc,APR_HOOK_MIDDLE);
|
|
Packit |
90a5c9 |
ap_hook_fixups(fixup_redir,NULL,NULL,APR_HOOK_MIDDLE);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
AP_DECLARE_MODULE(alias) =
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
STANDARD20_MODULE_STUFF,
|
|
Packit |
90a5c9 |
create_alias_dir_config, /* dir config creater */
|
|
Packit |
90a5c9 |
merge_alias_dir_config, /* dir merger --- default is to override */
|
|
Packit |
90a5c9 |
create_alias_config, /* server config */
|
|
Packit |
90a5c9 |
merge_alias_config, /* merge server configs */
|
|
Packit |
90a5c9 |
alias_cmds, /* command apr_table_t */
|
|
Packit |
90a5c9 |
register_hooks /* register hooks */
|
|
Packit |
90a5c9 |
};
|