use Apache::Constants qw(:common); use Apache::Request; use Apache::File; sub handler { my $r = Apache::Request->new(shift); my $serverFile = $r->param('file'); # needs some errorhandling here if $serverFile is not # submitted, invalid paths, ... # get $contenttype somehow; I always save it in a # database when I upload the file my $fh = Apache::File->new($serverFile); binmode($fh); unless ($fh) { $r->log_error("Can't open '$serverFile': $!"); } # unless else { $r->send_http_header($contenttype); $r->send_fd($fh); } # else return OK; } # handler #### RewriteEngine on RewriteRule /download/(.+)/(.*) /perl-bin/download.pl?file=$1;$2 #### package TransHandler; use warnings; use strict; use Apache::Constants qw(DECLINED); sub handler { my $r = shift; my $standardUri = "/pboard/PBoard.pm"; my $uri = $r->uri(); if ($uri =~ m|^/download/([^/]+)/(.+)|) { $r->uri($standardUri); $r->args("action=download2;file=$1"); return DECLINED; } # elsif return DECLINED; } # handler