简体   繁体   中英

apache server not redirecting correctly

I have written a module in apache which logs information when invoked lets say the url it is pointing at is localhost:12345/imp, i would like to subsequently after executing the code in this module redirect each request to different URL say for example www.cnn.com.

apr_table_add(r->headers_out, "Location","www.cnn.com" );
return HTTP_TEMPORARY_REDIRECT;

I have tried the above in my module however all it seems to do is call my module twice and it seems to be attempting to access localhost:12345/www/cnn/com. Surely there must be someone who has done similar to what i am attempting, can someone please advise?

Many thanks

The internet standard requires an absolute URI to follow a Location header, which means it must contain a scheme (eg, http:, https:, telnet:, mailto:).

You should use :

apr_table_add(r->headers_out, "Location","http://www.cnn.com" );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM