| 663 | } |
| 664 | |
| 665 | static int fixup_redir(request_rec *r) |
| 666 | { |
| 667 | void *dconf = r->per_dir_config; |
| 668 | alias_dir_conf *dirconf = |
| 669 | (alias_dir_conf *) ap_get_module_config(dconf, &alias_module); |
| 670 | char *ret; |
| 671 | int status; |
| 672 | |
| 673 | /* It may have changed since last time, so try again */ |
| 674 | |
| 675 | if ((ret = try_redirect(r, &status)) != NULL |
| 676 | || (ret = try_alias_list(r, dirconf->redirects, 1, &status)) |
| 677 | != NULL) { |
| 678 | if (ret == PREGSUB_ERROR) |
| 679 | return HTTP_INTERNAL_SERVER_ERROR; |
| 680 | if (ap_is_HTTP_REDIRECT(status)) { |
| 681 | if (dirconf->allow_relative != ALIAS_FLAG_ON || ret[0] != '/') { |
| 682 | if (ret[0] == '/') { |
| 683 | char *orig_target = ret; |
| 684 | |
| 685 | ret = ap_construct_url(r->pool, ret, r); |
| 686 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00675) |
| 687 | "incomplete redirection target of '%s' for " |
| 688 | "URI '%s' modified to '%s'", |
| 689 | orig_target, r->uri, ret); |
| 690 | } |
| 691 | if (!ap_is_url(ret)) { |
| 692 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00676) |
| 693 | "cannot redirect '%s' to '%s'; " |
| 694 | "target is not a valid absoluteURI or abs_path", |
| 695 | r->uri, ret); |
| 696 | return HTTP_INTERNAL_SERVER_ERROR; |
| 697 | } |
| 698 | } |
| 699 | /* append requested query only, if the config didn't |
| 700 | * supply its own. |
| 701 | */ |
| 702 | if (r->args && !ap_strchr(ret, '?')) { |
| 703 | ret = apr_pstrcat(r->pool, ret, "?", r->args, NULL); |
| 704 | } |
| 705 | apr_table_setn(r->headers_out, "Location", ret); |
| 706 | } |
| 707 | return status; |
| 708 | } |
| 709 | |
| 710 | return DECLINED; |
| 711 | } |
| 712 | |
| 713 | static const command_rec alias_cmds[] = |
| 714 | { |
nothing calls this directly
no test coverage detected