You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by pe...@neondawn.net on 2008/11/02 20:18:25 UTC

rewrite urls to modperl handler

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
<Location /ex_perl_h>
        SetHandler perl-script
        PerlResponseHandler ExamplePackage::WC
</Location>




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

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

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

Posted by Michael Peters <mp...@plusthree.com>.
perl@neondawn.net wrote:

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