Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Getting DocRoot of currently requested VirtualHost

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


jordan at viviotech

Oct 20, 2011, 3:04 PM

Post #1 of 2 (351 views)
Permalink
Getting DocRoot of currently requested VirtualHost

Hey Folks,

I'm pretty new to mod_perl but not new to programming in general. I'm
working on a mod_perl Apache module and I'm trying to find the way to
get the Document Root of the Currently requested VirtualHost.

I can get the currently requested domain name easily enough with:

my $servername = $r->get_server_name();

But getting the document root for that domain is proving to be a
challenge with VirtualHosts.

running this code:

my $document_root = $r->document_root();

Returns the first VirtualHost's document root, and not the document root
of the domain that's being requested.

I'm pretty sure I'm just missing something noobish here, but any
pointers on how to go about getting the document root of the current
requested VirtualHost would be *deeply* appreciated.

Thank you in advance!

--
Warm regards,
Jordan Michaels


jordan at viviotech

Oct 20, 2011, 4:39 PM

Post #2 of 2 (343 views)
Permalink
Re: Getting DocRoot of currently requested VirtualHost [In reply to]

Well, as what usually happens when you post to a mailing list and
publicly ask for help, I figured it out. I am humiliated to admit that
my problem was an apache configuration, so the DocRoot for the
VirtualHost was resolving to the first VirtualHost's DocRoot instead of
the proper VirtualHost's DocRoot. ::sigh::

This code:

my $document_root = $r->document_root();

returns the proper docroot for the virtualhost as long as your apache
settings are correct! A day wasted on something completely stupid!

Huge thanks to the folks that offered to help. Your support is deeply
appreciated. =)

Warm regards,
Jordan Michaels

On 10/20/2011 03:04 PM, Jordan Michaels wrote:
> Hey Folks,
>
> I'm pretty new to mod_perl but not new to programming in general. I'm
> working on a mod_perl Apache module and I'm trying to find the way to
> get the Document Root of the Currently requested VirtualHost.
>
> I can get the currently requested domain name easily enough with:
>
> my $servername = $r->get_server_name();
>
> But getting the document root for that domain is proving to be a
> challenge with VirtualHosts.
>
> running this code:
>
> my $document_root = $r->document_root();
>
> Returns the first VirtualHost's document root, and not the document root
> of the domain that's being requested.
>
> I'm pretty sure I'm just missing something noobish here, but any
> pointers on how to go about getting the document root of the current
> requested VirtualHost would be *deeply* appreciated.
>
> Thank you in advance!
>

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.