I'm beginning the development of a handler module and one of the tasks
of this module is change some request uri to another uri. I developed
this small module (code below), in this small module I compare if an
incoming request uri is equal a determinate uri if is true I change this
request uri for an another uri. I need now to direct this request to the
server for that it can serve this request and send the result to the
client.
thank's in advanced,
Tiago Semprebom
---------------------------------------------------------------------------
#include "httpd.h"
#include "ap_config.h"
#include <stdio.h>
static int my_new_handler(request_rec *r)
{
int APRStatus = OK;
if (r->method_number != M_GET)
return DECLINED;
if (r->finfo.filetype == 0) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,"print_test: %s",
r->uri);
if (!strcmp(r->uri,"/tiago/precisas/index1.htm")){
r->uri = "/tiago/imprecisas/index1.htm";
}
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,"print_test2: %s",
r->uri);
return HTTP_NOT_FOUND;
}
return (APRStatus);
}
static void register_hooks(apr_pool_t *p)
{
ap_hook_handler(my_new_handler,NULL,NULL,APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA my_handler =
{
STANDARD20_MODULE_STUFF,
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command apr_table_t */
register_hooks /* register hooks */
};
Yahoo! Search
Música para ver e ouvir: You're Beautiful, do James Blunt
