You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dave Viner <da...@pobox.com> on 2006/09/20 17:12:29 UTC

Proper apache config directive for a homepage

Hi,

I'm trying to set a special Perl handler for the "homepage" or index  
page of a site.  A directive like:

         <Location />
             SetHandler perl-script
             PerlResponseHandler Cool::Handler
         </Location>

causes all requests to be served by Cool::Handler.  However, I want  
only requests that match ^/$ to be served in that manner.  One hacky  
way I found to use mod_rewrite like is this:

         <Location /index>
             SetHandler perl-script
             PerlResponseHandler Cool::Handler
         </Location>
         RewriteRule ^/index.html  /index [R=301]

But, I think there must be a better way.  What's the best way for me  
to specify a handler which matches the "/" request?

thanks
dave


Re: Proper apache config directive for a homepage

Posted by Clinton Gormley <cl...@traveljury.com>.
On Wed, 2006-09-20 at 08:12 -0700, Dave Viner wrote:
> Hi,
> 
> I'm trying to set a special Perl handler for the "homepage" or index  
> page of a site.  A directive like:
> 
>          <Location />
>              SetHandler perl-script
>              PerlResponseHandler Cool::Handler
>          </Location>
> 
> causes all requests to be served by Cool::Handler.  However, I want  
> only requests that match ^/$ to be served in that manner.  One hacky  
> way I found to use mod_rewrite like is this:
> 
>          <Location /index>
>              SetHandler perl-script
>              PerlResponseHandler Cool::Handler
>          </Location>
>          RewriteRule ^/index.html  /index [R=301]
> 
> But, I think there must be a better way.  What's the best way for me  
> to specify a handler which matches the "/" request?


Try this:
<Location ~ "^/$" >

Clint