rewrite urls to modperl handler

rewrite urls to modperl handler

am 02.11.2008 20:18:25 von perl

Hi all,

I am new to mod_perl and am having a difficult time with rewrites.
Either I am doing it the most wrong way, or it's so easy that I'm over
looking it. I have searched and found nothing that seems to relate to
what I want.

I am working on a perl based wiki, to help me learn more about how perl
works. I am looking for a way to create friendly URLs that get passed to a
mod_perl handler, without having the handler location name in the url.


For instance currently I have:
http://example.com/ex_perl_h/docName

and I want:
http://example.com/docName



From my apache config:

PerlModule ExamplePackage::WC

SetHandler perl-script
PerlResponseHandler ExamplePackage::WC





I have mod rewrite setup to redirect request that don't an existing
file or directory to the perl handler.


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*) /ex_perl_h [L]


but this doesn't work.



I think what I am looking for is a mod_perl based front controler that
would handle ALL site request for URLs that don't point to a real file
or directory.

So for http://example.com/docName docName would be passed somehow to the
mod_perl script ExamplePackage::WC , similar to
http:://example.com/wc.pl?arg=docName , but done in the mod_per style.

Thanks.

Uk1ah Smith

Re: rewrite urls to modperl handler

am 03.11.2008 14:31:05 von mpeters

perl@neondawn.net wrote:

> I have mod rewrite setup to redirect request that don't an existing
> file or directory to the perl handler.
>
>
> RewriteEngine On
> RewriteBase /
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule ^/(.*) /ex_perl_h [L]
>

>
> but this doesn't work.

Why do you mean by "this doesn't work". There are lots of ways for it to work incorrectly. Should we
guess? Ok, my guess is that's it's going to /ex_perl_h but not /ex_perl_h/docName. Try changing your
RewriteRule to this:

RewriteRule ^/(.*) /ex_perl_h/$1 [L]

--
Michael Peters
Plus Three, LP