httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thuan Tran" <tmth...@tma.com.vn>
Subject [users@httpd] all requests are rooted to apache custom module
Date Tue, 18 May 2004 14:23:42 GMT
Hi all,
I am new with Apache. I wrote a apache custom module and activated it with
apxs tool as:
bin/apxs -i -a -c mod_tut1.c

After that, these is a directive to load my module in httpd.conf as
following:

# Example:
# LoadModule foo_module modules/mod_foo.so
 LoadModule tut1_module        modules/mod_tut1.so


But after restarting Apache server, all requests are rooted to this module.
For example, I tried to access http://localhost:80, it always returns result
as following:

Hello 192.168.97.247
Testing Who would take this book seriously if the first example didn't say
"hello world"?

I expect only whenever I access http://localhost:80/tut1 my module must be
invoked.
Please give a hand to solve it.

could I set the handler for my module? how could I do that?

Thanks in advance,
Thuan.



----------- This is source code of my module------------------------

#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
#include "ap_compat.h"

static int mod_tut1_method_handler (request_rec *r)
{
const char* hostname;
  r->content_type = "text/html";
// ap_send_http_header(r);
 hostname =
ap_get_remote_host(r->connection,r->per_dir_config,REMOTE_NAME,NULL);
  ap_rputs("<HTML>\n"                           ,r);
 ap_rputs("<HEAD>\n"                           ,r);
 ap_rputs("<TITLE>Hello There</TITLE>\n"       ,r);
 ap_rputs("</HEAD>\n"                          ,r);
 ap_rputs("<BODY>\n"                           ,r);
 ap_rprintf(r,"<H1>Hello %s</H1>\n"            ,hostname);
 ap_rputs("Testing Who would take this book seriously if the first example
didn't\n",r);   ap_rputs("say \"hello world\"?\n"             ,r);
 ap_rputs("</BODY>\n"                          ,r);
 ap_rputs("</HTML>\n"                          ,r);
  return OK;
}

static void mod_tut1_register_hooks (apr_pool_t *p)
{
        ap_hook_handler(mod_tut1_method_handler, NULL, NULL, APR_HOOK_LAST);
}

module AP_MODULE_DECLARE_DATA tut1_module =
{
        STANDARD20_MODULE_STUFF,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        mod_tut1_register_hooks,                        /* callback for
registering hooks */
};


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message