httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Lewis <>
Subject Re: [Apache Module] Request External Redirection
Date Mon, 14 Jan 2008 15:49:23 GMT
karim Bendadda wrote:
> Thank you for your help!
> How can I call the Redirect directive into the module??, In fact in the
> module I have a function that make an LDAP connection I want to do something
> like that:
> request_rec* my_request; //The request with new information
> if(my_function(user_is_defined_in_ldap)==true)
> Redirect my_request new_Url
> else
> Do_nothing

Do_nothing should be "return DECLINED" in the handler.  Redirect 
my_request new_URL should be almost verbatim the code that the Doc 
(Peter Poeml) included.  Let me just snip down through to his example to 
make it a little more obvious.

>> In your handler, you would do something like this to implement the latter:
>>     /* set a "Location:" header and 302 redirect. */
>>     /* assemble the url by appending the filename to a baseurl */
>>     uri = apr_pstrcat(r->pool, baseurl, filename, NULL);
>>     apr_table_setn(r->headers_out, "Location", uri);

And there is the "how to".  Recall, though, that this kind of thing 
shouldn't be in an input filter, but a handler.  (It may, in theory, be 
workable in a filter, but a filter is supposed to alter input not handle 
requests, and a handler is supposed to give the response of the 302 or 
data or decline to handle it.)

Joseph Lewis <>
"Divide the fire, and you will sooner put it out." - Publius Syrus

View raw message