You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by eeadev dev <ee...@gmail.com> on 2017/09/20 14:31:38 UTC

[users@httpd] how to externally redirect?

how can I redirect externally from my module?

for instance under certain condition I need to go to www.google.com

I saw this api
void
<https://ci.apache.org/projects/httpd/trunk/doxygen/group__MOD__ISAPI.html#gacd6cdbf73df3d9eed42fa493d9b621a6>
  ap_internal_redirect
<https://ci.apache.org/projects/httpd/trunk/doxygen/group__APACHE__CORE__REQ.html#gac3338d5cb2db319ab2140a48900c87e9>
(const
char *new_uri, request_rec
<https://ci.apache.org/projects/httpd/trunk/doxygen/structrequest__rec.html>
 *r
<https://ci.apache.org/projects/httpd/trunk/doxygen/group__MOD__PROXY.html#gac68e921ed15f71060d618adb662a84f6>
)



but it seems to be for internal redirect only, no?


Thanks

Re: [users@httpd] how to externally redirect?

Posted by eeadev dev <ee...@gmail.com>.
thank you, Eric.
I did it

        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                    " do_redirect");


        r->hostname = "google.com";
        ret = r->unparsed_uri;
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                    " do_redirect 111");

        ret = ap_construct_url(r->pool, ret, r);
        apr_table_setn(r->headers_out, "Location", ret);
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                    " do_redirect 117");

it kind of work but it goes to http://google.com/moduleA where moduleA is
my module name.
Do u know how to avoid it?

thank you again!

2017-09-20 10:47 GMT-07:00 Eric Covener <co...@gmail.com>:

> I meant read it an editor of your choice to see how it's done.
>
> On Wed, Sep 20, 2017 at 11:21 AM, eeadev dev <ee...@gmail.com> wrote:
> > shall I import the mod_alias.c file in my project or if I install the
> module
> > mod_alias.c, I can use its functions?
> >
> > 2017-09-20 16:34 GMT+02:00 Eric Covener <co...@gmail.com>:
> >>
> >>
> >>
> >> On Wed, Sep 20, 2017 at 10:31 AM, eeadev dev <ee...@gmail.com> wrote:
> >>>
> >>> how can I redirect externally from my module?
> >>
> >>
> >> Have a look at how fixup_redir() in mod_alias.c works. Set a Location
> >> header and return 301/302/...
> >> Note: This may only work in certain hooks (fixup and handler definitly)
> >>
> >
>
>
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] how to externally redirect?

Posted by Eric Covener <co...@gmail.com>.
I meant read it an editor of your choice to see how it's done.

On Wed, Sep 20, 2017 at 11:21 AM, eeadev dev <ee...@gmail.com> wrote:
> shall I import the mod_alias.c file in my project or if I install the module
> mod_alias.c, I can use its functions?
>
> 2017-09-20 16:34 GMT+02:00 Eric Covener <co...@gmail.com>:
>>
>>
>>
>> On Wed, Sep 20, 2017 at 10:31 AM, eeadev dev <ee...@gmail.com> wrote:
>>>
>>> how can I redirect externally from my module?
>>
>>
>> Have a look at how fixup_redir() in mod_alias.c works. Set a Location
>> header and return 301/302/...
>> Note: This may only work in certain hooks (fixup and handler definitly)
>>
>



-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] how to externally redirect?

Posted by eeadev dev <ee...@gmail.com>.
shall I import the mod_alias.c file in my project or if I install the
module mod_alias.c, I can use its functions?

2017-09-20 16:34 GMT+02:00 Eric Covener <co...@gmail.com>:

>
>
> On Wed, Sep 20, 2017 at 10:31 AM, eeadev dev <ee...@gmail.com> wrote:
>
>> how can I redirect externally from my module?
>>
>
> ​Have a look at how fixup_redir() in mod_alias.c works. Set a Location
> header and return 301/302/...
> Note: This may only work in certain hooks (fixup and handler definitly)
> ​
>
>

Re: [users@httpd] how to externally redirect?

Posted by Eric Covener <co...@gmail.com>.
On Wed, Sep 20, 2017 at 10:31 AM, eeadev dev <ee...@gmail.com> wrote:

> how can I redirect externally from my module?
>

​Have a look at how fixup_redir() in mod_alias.c works. Set a Location
header and return 301/302/...
Note: This may only work in certain hooks (fixup and handler definitly)
​