httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc apocalypse17" <apocalyps...@gmx.de>
Subject Re: Change Request-Header before mod_rewrite
Date Mon, 11 Jun 2012 18:37:12 GMT
Thank you very much!

That worked fine for me.

Now I got another problem. If I enable my module and call it up with "localhost" in my browser
a 404 is returned although there is a index.html in the root directory of the webserver. If
I disable my module and call it up with "localhost" the index.html ist presented in the browser.
So whats the problem with my module?

The configuration of my module is the following:

<Location />
    SetHandler example-handler
</Location>


-------- Original-Nachricht --------
> Datum: Tue, 05 Jun 2012 00:09:19 +0200
> Von: Daniel Gruno <rumble@cord.dk>
> An: modules-dev@httpd.apache.org
> Betreff: Re: Change Request-Header before mod_rewrite

> On 06/04/2012 10:53 PM, Marc apocalypse17 wrote:
> > Hi all,
> >
> > I just developed my first apache module following the tutorial on the
> apache website. The module is responsible for adding one header value to the
> active request which must be checked in a mod_rewrite ReWriteCondition.
> > The problem is, that this value never reaches the mod_rewrite Rule. The
> Header just behaves the same as the original request. Does anyone know why?
> What am I doing wrong?
> >
> > My module looks like this:
> >
> > static int helloworld_handler(request_rec* r){
> >     if (!r->main) {
> >         apr_table_setn(r->headers_in, "X-CUSTOM-HEADER", "1");
> >     }
> >     return DECLINED;
> > }
> >
> > static void register_hooks(apr_pool_t* pool){
> >     ap_hook_handler(helloworld_handler, NULL, NULL, APR_HOOK_FIRST);
> > }
> >
> > module AP_MODULE_DECLARE_DATA helloworld_module = {
> >     STANDARD20_MODULE_STUFF,
> >     NULL,
> >     NULL,
> >     NULL,
> >     NULL,
> >     example_directives,
> >     register_hooks
> > };
> >
> > The .htacces file looks like this:
> >
> > RewriteEngine on
> > RewriteCond %{HTTP:X-CUSTOM-HEADER} 1 [NC]
> > RewriteRule from.html to.html
> >
> > The Rewrite-Rule is never executes fine. It always show the content of
> from.html.
> >
> >
> > Thank you in advance,
> > Marc
> >
> As Ben said, mod_rewrite is invoked far earlier than your handler
> (handlers are invoked last), since it hooks onto the translation part of
> the http process. If you intend for your module to do the same, you
> change your hook function accordingly:
> 
> static void register_hooks(apr_pool_t* pool){
>     ap_hook_translate_name(helloworld_handler, NULL, NULL,
> APR_HOOK_FIRST-1);
> }
>  
> 
> This will eventually be covered by the module guide in the docs (as soon
> as I get some time off to write it)
> 
> With regards,
> Daniel.

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

Mime
View raw message