perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Lindner <lind...@inuus.com>
Subject Re: mixing cgi-bin & mod_perl
Date Thu, 20 Dec 2001 20:55:29 GMT
On Thu, Dec 20, 2001 at 09:41:31PM +0100, Miroslav Madzarevic wrote:
>     The scenario:
> There are two folders
> /cgi-bin        with plain perl cgi
> /mod-perl       with Apache::Registry scripts
> 
> The application is being moved from cgi to mod_perl (Apache::Registry) one
> script at a time.
> My friend has a strange idea.
> He wants to mix cgi-bin & mod_perl by testing all of the scripts in
> cgi-bin and putting one cgi-script at a time into mod-perl folder.
> He wants to do this internaly in Apache, changing the request for
> a particular script so for example when you reference /cgi-bin/some_scr.pl
> you actually end with /mod-perl/some_scr.pl. He doesn't want to
> change the <a href> code from html files to stop pointing at /cgi-bin.
> By moving all of them one at a time all of the application will
> eventually end up working under mod_perl.
> 
> How can he do that ?
> 
> He thought of using mod_proxy or mod_rewrite.
> The scripts are badly written and have been developed for three years
> so far by various perl "programmers".

I'd use mod_rewrite or, even better, use the power of the
PerlTransHandler..  Activate the following handler by adding

  PerlTransHandler Moo::my_trans_handler

to your httpd.conf.  In your example it will check for

  /usr/local/apache/cgi-bin/some_scr.pl_mod_perl_me

If that file exists we rewrite the URL to use the /mod-perl prefix
internally.


sub Moo::my_trans_handler {
  my $r = shift;
  my $uri = $r->uri;

  return DECLINED unless ($uri =~ s,^/cgi-bin/,,);
  
  if (-f "/usr/local/apache/cgi-bin/${uri}_mod_perl_me") {
    $uri = = "/mod-perl/$uri
    $r->uri("/mod-perl/$uri");
  }
  return DECLINED;
}
  

-- 
Paul Lindner    lindner@inuus.com   ||||| | | | |  |  |  |   |   |

    mod_perl Developer's Cookbook   http://www.modperlcookbook.org
         Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm

Mime
View raw message