Gabriel C Millerd wrote:

> On Thu, 13 Jun 2002, Geoffrey Young wrote:
> 
> 
>>sounds like a job for a PerlTransHandler...
>>
>>   if ($not_ok) {
>>     $r->uri('/not_ok_page.html');
>>     return DECLINED;
>>   }
>>
>>
> 
> this works great until i run into an Alias or a mod_rewite rule it seems.


that's odd.  the above code essentially acts as though the user 
entered /not_ok_page.html in their browser all by themselves.  maybe I 
  incorrectly assumed that's what you were looking for?


> what is the proper way to indicate success here? ora's "writing apache
> modules" has this method and the method omitting '$r->filename()' line -
> which i have not been able to get to work.


Apache only gives handlers one shot at translating the URI to a 
filename.  So, you can either trick apache by changing the URI and 
returning DECLINED, which lets Apache handle the translation for you, 
or map the filename yourself (as you do below) and return OK.


> 
> one step away from this .. perhaps a set of logic to act differently is
> needed for different requests.
> 
> sub handler {
>     my $r=shift;
>     if(Apache::MonDiag($r) {
>         $r->filename($r->document_root . $r->uri);
>         return OK;
>     } else {
>         $r->warn("Apache::MonDiag($state)");
>         my $url=$r->dir_config('MonDiagRedirect');
>         $r->content_type('text/html');
>         $r->header_out(Location=>$url);
>         return REDIRECT;
>     }
> }


it's early here, and I haven't had my coffee yet, but what you're 
written should be essentially the same as the short snipped I provided 
(save the possibility of redirecting to an offsite URL).

HTH

--Geoff



Reply via email to