httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "karim Bendadda" <kakib...@gmail.com>
Subject Re: [Apache Module] Request External Redirection
Date Mon, 14 Jan 2008 17:55:40 GMT
I did that , I have a redirection to the new url but it seems that it's just
a redirection , the HTTP request doesn't get in the new URl: there is my
code:


static int my_module_handler (request_rec *r) {
   apr_table_setn( r->headers_out, "Location","http://10.112.3.20/test");
return HTTP_MOVED_TEMPORARILY;
}

module AP_MODULE_DECLARE_DATA my_module_module = {
    STANDARD20_MODULE_STUFF,
    NULL,
    NULL,
    my_module_config,
    NULL,
    my_module_cmds,
    my_module_hooks
};


    Really sorry for the * *inconvenience ....


On 1/14/08, Joe Lewis <joe@joe-lewis.com> wrote:
>
> karim Bendadda wrote:
> > Sorry but I'm a beginer on developping Apache modules...Thank you for
> your
> > patience...
> >
> > I dont't understand this:
> >
> >
> >> /* set a "Location:" header and 302 redirect. */
> >>
> >
> > Does'it mean to make this??:
> >
>
> No, that is just a C comment.
>
> > <Location /my_module>
> > Redirect /my_module http://10.112.3.20/test
> > </Location>
> >
>
> This is a pre-build "hard coded" redirection module that does something
> very similar to :
>
> > static int my_module_handler (request_rec *r){
> >
> >    /* assemble the url by appending the filename to a baseurl */
> >
> >    uri = apr_pstrcat(r->pool, "http://10.112.3.20/test", "my_module",
> > NULL);/*????*/
> >
> >     apr_table_setn(r->headers_out, "my_module", uri);
> >
> >      return HTTP_MOVED_TEMPORARILY;
> > }
> >
> >
> >
>
> However, you have two things that are wrong in your code.  The resulting
> uri would be "http://10.112.3.20/testmy_module" because the
> apr_pstrcat() function tacks the two strings together.  If you already
> know the full URL, you can skip the uri= line and set the headers_out.
>
> Which brings up the other issue.  The apr_table_setn must be setting a
> "Location" header in order to meet the redirection standard.  Yours is
> setting "my_module".  Replace "my_module" with "Location", and then
> whatever is in the uri parameter is going to the web browser as the
> location header, and it should contact the new server/resource.
>
> Joe
> --
> Joseph Lewis <http://sharktooth.org/>
> "Divide the fire, and you will sooner put it out." - Publius Syrus
>



-- 
Karim

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message