You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Doug MacEachern <do...@covalent.net> on 2000/12/22 05:39:04 UTC

Re: Handler is preventing redirects on missing trailing / ?

On Wed, 11 Oct 2000, Clayton Mitchell wrote:
 
> I then noticed that URI's of directories lacking a trailing '/' were not
> being redirected in the browser and so relative links started to break.

since your PerlHandler is handling the directory, you need to manage that.
mod_autoindex and mod_dir both do it themselves, in different ways, here's
mod_dir:
    if (r->uri[0] == '\0' || r->uri[strlen(r->uri) - 1] != '/') {
        char *ifile;
        if (r->args != NULL)
            ifile = ap_pstrcat(r->pool, ap_escape_uri(r->pool, r->uri),
                            "/", "?", r->args, NULL);
        else
            ifile = ap_pstrcat(r->pool, ap_escape_uri(r->pool, r->uri),
                            "/", NULL);

        ap_table_setn(r->headers_out, "Location",
                  ap_construct_url(r->pool, ifile, r));
        return HTTP_MOVED_PERMANENTLY;
    }