httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Noordhuis <i...@bnoordhuis.nl>
Subject Re: Change Request-Header before mod_rewrite
Date Mon, 04 Jun 2012 21:30:36 GMT
On Mon, Jun 4, 2012 at 10:53 PM, Marc apocalypse17 <apocalypse17@gmx.de> 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

mod_rewrite.c does most of the interesting work in a translate_name
hook. By the time your handler hooks run, it's probably too late.

Mime
View raw message