I am using apache 2.0/2.2, in my output filter, I
would like to have the ability to redirect. Some
tests indicated that I can redirect to a page on the
same site, but not to an external site.
Here is my code for redirect:
char* location =
apr_table_get(r->headers_out, "Location");
//Note this Location is set by my filter during the
process, so I know I need to do a redirect.
if(location && location[0])
{
//r->status = 301;
r->method = apr_pstrdup(r->pool, "GET");
r->method_number = M_GET;
apr_table_unset(r->headers_in, "Content-Length");
ap_remove_output_filter(my_filter);
ap_internal_redirect_handler(location, r);
return APR_SUCCESS;
}
//tests: (if my site is http://localhost/foo)
and when http://localhost/foo/bar.html (my test
page)is loaded I want to redirect it to
a) /foo/foo2/existing.html (works)
b) http://localhost/foo/foo2/existing.html (works)
c) http://www.google.com (does not work), instead I
get http://localhost/foo displayed on the browser.
Is there anything I did is incorrect? I noticed the
method is called "*internal_redirect*", but did not
know another one for "external redirect".
Thanks,
John