| 605 | } |
| 606 | |
| 607 | static int translate_alias_redir(request_rec *r) |
| 608 | { |
| 609 | ap_conf_vector_t *sconf = r->server->module_config; |
| 610 | alias_server_conf *serverconf = ap_get_module_config(sconf, &alias_module); |
| 611 | char *ret; |
| 612 | int status; |
| 613 | |
| 614 | if (r->uri[0] != '/' && r->uri[0] != '\0') { |
| 615 | return DECLINED; |
| 616 | } |
| 617 | |
| 618 | if ((ret = try_redirect(r, &status)) != NULL |
| 619 | || (ret = try_alias_list(r, serverconf->redirects, 1, &status)) |
| 620 | != NULL) { |
| 621 | if (ret == PREGSUB_ERROR) |
| 622 | return HTTP_INTERNAL_SERVER_ERROR; |
| 623 | if (ap_is_HTTP_REDIRECT(status)) { |
| 624 | alias_dir_conf *dirconf = (alias_dir_conf *) |
| 625 | ap_get_module_config(r->per_dir_config, &alias_module); |
| 626 | if (dirconf->allow_relative != ALIAS_FLAG_ON || ret[0] != '/') { |
| 627 | if (ret[0] == '/') { |
| 628 | char *orig_target = ret; |
| 629 | |
| 630 | ret = ap_construct_url(r->pool, ret, r); |
| 631 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00673) |
| 632 | "incomplete redirection target of '%s' for " |
| 633 | "URI '%s' modified to '%s'", |
| 634 | orig_target, r->uri, ret); |
| 635 | } |
| 636 | if (!ap_is_url(ret)) { |
| 637 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00674) |
| 638 | "cannot redirect '%s' to '%s'; " |
| 639 | "target is not a valid absoluteURI or abs_path", |
| 640 | r->uri, ret); |
| 641 | return HTTP_INTERNAL_SERVER_ERROR; |
| 642 | } |
| 643 | } |
| 644 | /* append requested query only, if the config didn't |
| 645 | * supply its own. |
| 646 | */ |
| 647 | if (r->args && !ap_strchr(ret, '?')) { |
| 648 | ret = apr_pstrcat(r->pool, ret, "?", r->args, NULL); |
| 649 | } |
| 650 | apr_table_setn(r->headers_out, "Location", ret); |
| 651 | } |
| 652 | return status; |
| 653 | } |
| 654 | |
| 655 | if ((ret = try_alias(r)) != NULL |
| 656 | || (ret = try_alias_list(r, serverconf->aliases, 0, &status)) |
| 657 | != NULL) { |
| 658 | r->filename = ret; |
| 659 | return OK; |
| 660 | } |
| 661 | |
| 662 | return DECLINED; |
| 663 | } |
| 664 |
nothing calls this directly
no test coverage detected