MCPcopy Create free account
hub / github.com/apache/httpd / try_redirect

Function try_redirect

modules/mappers/mod_alias.c:478–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476}
477
478static char *try_redirect(request_rec *r, int *status)
479{
480 alias_dir_conf *dirconf =
481 (alias_dir_conf *) ap_get_module_config(r->per_dir_config, &alias_module);
482
483 if (dirconf->redirect_set) {
484 apr_uri_t uri;
485 const char *err = NULL;
486 char *found = "";
487
488 if (dirconf->redirect) {
489
490 found = apr_pstrdup(r->pool,
491 ap_expr_str_exec(r, dirconf->redirect, &err));
492 if (err) {
493 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02826)
494 "Can't evaluate redirect expression: %s", err);
495 return PREGSUB_ERROR;
496 }
497
498 apr_uri_parse(r->pool, found, &uri);
499 /* Do not escape the query string or fragment. */
500 found = apr_uri_unparse(r->pool, &uri, APR_URI_UNP_OMITQUERY);
501 found = ap_escape_uri(r->pool, found);
502 if (uri.query) {
503 found = apr_pstrcat(r->pool, found, "?", uri.query, NULL);
504 }
505 if (uri.fragment) {
506 found = apr_pstrcat(r->pool, found, "#", uri.fragment, NULL);
507 }
508
509 }
510
511 *status = dirconf->redirect_status;
512 return found;
513
514 }
515
516 return NULL;
517}
518
519static char *try_alias_list(request_rec *r, apr_array_header_t *aliases,
520 int is_redir, int *status)

Callers 2

translate_alias_redirFunction · 0.85
fixup_redirFunction · 0.85

Calls 2

ap_get_module_configFunction · 0.85
ap_expr_str_execFunction · 0.85

Tested by

no test coverage detected