FAQ
Hey,

One thing that would be nice to have in the Catalyst::Engine::CGI is to
optionally prefer $ENV{REQUEST_URI} to $ENV{PATH_INFO} when setting $c->path.

With mod_rewrite, it would let you have URLs like foo.com/ping instead of
foo.com/index.cgi/ping.

I use an htaccess setup like this:

Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex index.cgi
RewriteEngine On
# Next two lines allow requests for real
# files to still go through the webserver
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# All other requests go to index.cgi
RewriteRule ^(.*) index.cgi [L,QSA]

Here is the changed Catalyst::Engine::CGI:

--- CGI.pm.orig Tue Apr 26 02:35:42 2005
+++ CGI.pm Tue Apr 26 02:36:59 2005
@@ -175,7 +175,7 @@
$base = $base->canonical->as_string;
}

- my $path = $ENV{PATH_INFO} || '/';
+ my $path = ($c->config->{engine}{rewrite_mode} ? $ENV{REQUEST_URI} : $ENV{PATH_INFO}) || '/';
$path =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
$path =~ s/^\///;

Cheers,
Keith

Search Discussions

  • Christian Hansen at Apr 28, 2005 at 7:48 pm

    On 2005-04-26, at 11.52, Keith Grennan wrote:

    Hey,

    One thing that would be nice to have in the Catalyst::Engine::CGI is to
    optionally prefer $ENV{REQUEST_URI} to $ENV{PATH_INFO} when setting
    $c->path.
    Thank you for your patch! Unfortunately it will not make it to trunk.

    This can be solved by configuring Apache to handle CGI scripts without
    extension, or by using ScriptAlias directive. If this is not possible
    you can still do it your CGI script:

    #!/usr/bin/perl -w

    BEGIN { $ENV{CATALYST_ENGINE} = 'CGI' }

    use strict;
    use FindBin;
    use lib "$FindBin::Bin/../lib";
    use MyApp;

    $ENV{PATH_INFO} = $ENV{REQUEST_URI};

    MyApp->run;

    1;

    --

    Christian Hansen
    nGmedia
    +46 40 660 17 50

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedApr 26, '05 at 11:51a
activeApr 28, '05 at 7:48p
posts2
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

Christian Hansen: 1 post Keith Grennan: 1 post

People

Translate

site design / logo © 2022 Grokbase