You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Rodney Broom <rb...@home.com> on 2000/10/13 01:01:55 UTC

Recognizing server config, like Aliases, from modules

Hi all,

I've got a set of new modules that do things like session handling, URI
rewriting, authentication, etc. I've got a set of tests to prevent some rewrite
problems that look like this:

    if ($uri =~ m|^/cgi-bin/|) {
        return DECLINED;
    if ($uri =~ m|^/icons/|) {
        return DECLINED;
etc.

This is done to allow access to /cgi-bin and /icons and the like without
rewriting the URI. UserDir is the same way. The problem is the fact that now
folks can't ajust the conf file without ajusting the module, too. I guess I
could slurp up the config file on load and figure it out for myself, but that
doesn't seem very healthy or very efficient. What I'd like is a method:

  $r->get_aliases

But I don't guess that exists, huh? Any thoughts?

----
Rodney Broom



Re: Recognizing server config, like Aliases, from modules

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 12 Oct 2000, Rodney Broom wrote:

> Hi all,
> 
> I've got a set of new modules that do things like session handling, URI
> rewriting, authentication, etc. I've got a set of tests to prevent some rewrite
> problems that look like this:
> 
>     if ($uri =~ m|^/cgi-bin/|) {
>         return DECLINED;
>     if ($uri =~ m|^/icons/|) {
>         return DECLINED;
> etc.
> 
> This is done to allow access to /cgi-bin and /icons and the like without
> rewriting the URI. UserDir is the same way. The problem is the fact that now
> folks can't ajust the conf file without ajusting the module, too. I guess I
> could slurp up the config file on load and figure it out for myself, but that
> doesn't seem very healthy or very efficient. What I'd like is a method:
> 
>   $r->get_aliases
> 
> But I don't guess that exists, huh? Any thoughts?

no, because those structures are private do mod_alias.
you can actually call the mod_alias translate handler directly to see if
there is an Alias configured for the uri:

use Apache::Module ();

my $rr = $r->lookup_uri($r->uri);
my $mod_alias = Apache::Module->top_module->find("mod_alias");
my $rc = $mod_alias->translate_handler->($rr);

if ($rc == OK) {
    #an Alias matched
}

or, if you configure your Alias' with <Perl> config, you can save it to
match against yourself.