[cgiapp] CGI::Application::Dispatch

Cees Hek ceeshek at gmail.com
Wed Feb 11 19:17:47 EST 2009


On Wed, Feb 11, 2009 at 5:45 AM, Lyle <webmaster at cosmicperl.com> wrote:
> Hi All,
>  I was just looking at this modules docs and I noticed it says:-
>
> It will translate a URI like this (under mod_perl):
>
>   /app/module_name/run_mode
>
> or this (vanilla cgi)
>
>   /app/index.cgi/module_name/run_mode
>
> I'm guess it might have come up before, but might be worth mentioning
> anyway. If you are on Vanilla CGI, you can rename you index.cgi to just
> index, then use Apache config like:-
> <Files "index">
>  SetHandler cgi-script
> </Files>
>
> To get URLs like:-
> yourdomain.com/index/run_mode

There is another easier way to do this using the mod_negotiation
module and the MultiViews option.

<Directory /var/www>
  Options MultiViews
</Directory>

This allows you to leave your script as index.cgi or foo.cgi or even
foo.html.  Then when you request /foo/index and /foo/index does not
exist, apache will look for /foo/index.* and pick the most appropriate
file it finds.

This is also useful for sending out PNG files to browsers that can
accept them, and GIF files to ones that don't.  Just put both files in
the same directory, and in your IMG tag leave off the extension.
Apache will look at the incoming headers to pick the most appropriate
file to send out (This has the potential to mess up reverse proxies,
but you can add a Vary: User-Agent header to fix that at the cost of
reducing your cache effectiveness).

See the docs for more info:
http://httpd.apache.org/docs/2.0/mod/mod_negotiation.html

Cheers,

Cees


More information about the cgiapp mailing list