Hey folks, I'm trying to learn how to use mod_perl to change document_root on the fly, but I'm having a lot of difficulty with it. Here's the setup:
Apache/2.0.50, mod_perl/1.99_11 Perl/v5.8.4 PHP/4.3.8 Server
I'm calling the code this way:
PerlTransHandler MyApache::RewriteURI
...and this is what RewriteURI looks like (yes, wholly ripped off from the documentation...):
################################### package MyApache::RewriteURI;
use strict; use warnings;
use Apache::RequestRec; use Apache::RequestUtil;
use Apache::Const -compile => qw(DECLINED);
sub handler { my $r = shift;
$r->document_root("/home/ddellacosta/web_dev/stuff/htdocs");
warn "DOCUMENT_ROOT = " . $r->document_root() . "\n";
$r->uri("forgot.phtml");
return Apache::DECLINED; }
1; ###################################
When I try to run this, I get an Internal Server Error and this message in the error_log:
Usage: Apache::RequestRec::document_root(r) at /usr/lib/apache2/lib/perl/MyApache/RewriteURI.pm line 14.\n
Floating around on the web are dozens of examples of being able to set document_root the way I'm trying to set it. However, I cannot seem to get this to work. Am I doing something ridiculously obviously wrong? I am a mod_perl newbie.
Right. The examples you've found are from mod_perl 1, Apache2 has this in its docs:
/** * Retrieve the document root for this server * @param r The current request * @warning Don't use this! If your request went through a Userdir, or * something like that, it'll screw you. But it's back-compatible... * @return The document root * @deffunc const char *ap_document_root(request_rec *r) */ AP_DECLARE(const char *) ap_document_root(request_rec *r);
we haven't had a chance yet to work on figuring out how to solve it for mp2. Let me do some research and I'll be back to you shortly.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
-- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html