You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Milo Hyson <mi...@cyberlifelabs.com> on 2002/03/06 23:25:14 UTC
Virtual locations in mod_perl
I'm having trouble understanding how to configure mod_perl to execute a
handler when called with a virtual location (i.e. one that does not directly
map to anything in the server's filesystem). I know it's possible because
packages like PageKit do it. I tried hacking through PageKit's code, but it
didn't answer any questions.
My problem is that whenever Apache receives a URL for a virtual location, its
default translation handler converts it into a directory index (index.html),
which of course doesn't exist. The end result is a 403. Now I can write my
own PerlTransHandler to intercept requests for my specific locations and
pretend to translate them, but that's a pain and PageKit seems to work
without doing that.
Does anybody have any insight they could offer? Thanks in advance. :)
--
Milo Hyson
CyberLife Labs, LLC
Re: Virtual locations in mod_perl
Posted by Ernest Lergon <er...@virtualitas.net>.
Milo Hyson wrote:
>
> [snip]
> handler ... virtual location (i.e. one that does not directly
> map to anything in the server's filesystem).
> [snip]
>
Hi Milo,
that's easy. This is an anonymized excerpt of httpd.conf for a
multilanguage shop. None of the named locations exists on the server:
<VirtualHost *>
ServerName www.myshop.xxx
ServerAlias *.myshop.xxx
ServerAlias myshop.xxx
ServerAdmin webmaster@myshop.xxx
DocumentRoot /home/myshop/public_html
CustomLog /home/myshop/log/access_log combined
ErrorLog /home/myshop/log/error_log
ScriptAlias /cgi-bin/ /home/myshop/public_html/cgi-bin/
# This delivers the main page:
<LocationMatch "^(/|/index|/de|/de/|/de/index)$">
SetHandler perl-script
PerlSetVar Language de
PerlHandler MyShop::Index
</LocationMatch>
# This delivers catalogue pages:
<Location /de/catalog>
SetHandler perl-script
PerlSetVar Language de
PerlHandler MyShop::Catalog
</Location>
# Detailed view of articles:
<Location /de/zoom>
SetHandler perl-script
PerlSetVar Language de
PerlHandler MyShop::Zoom
</Location>
# A search form (In/Out):
<Location /de/search>
SetHandler perl-script
PerlSetVar Language de
PerlHandler MyShop::Search
</Location>
# and more...
# Same in English:
<LocationMatch "^(/|/index/en|/en/|/en/index)$">
SetHandler perl-script
PerlSetVar Language en
PerlHandler MyShop::Index
</LocationMatch>
# and as above...
</VirtualHost>
Hope, that helps.
Ernest
--
*********************************************************************
* VIRTUALITAS Inc. * *
* * *
* European Consultant Office * http://www.virtualitas.net *
* Internationales Handelszentrum * contact:Ernest Lergon *
* Friedrichstraße 95 * mailto:Ernest@virtualitas.net *
* 10117 Berlin / Germany * ums:+49180528132130266 *
*********************************************************************