Perl question

Victor Odhner plug-discuss@lists.plug.phoenix.az.us
Wed, 10 Jul 2002 17:51:51 -0700


I'm not arguing with the other suggestions, but
let me offer another which I think is the
"proper" solution.

You can easily create a directory all of whose
files will be treated as CGIs, and not visible
as downloadable files; and thus they do not need
to have any suffix, let alone any specific suffix,
to be run as CGIs.

You need a name for the directory containing these
CGI scripts.  So let's make "testm" a directory.
Then add this line to your Apache config:

  ScriptAlias /testm/ /usr/local/apache/cgiprogs/

The /usr/local/apache/cgiprogs/ directory name is
totally arbitrary, so I purposely made it different
from "testm" and did not include the name "cgi-bin".

Name your program "foo" (i.e. anything, with no
special suffix) in that cgiprogs directory.
Note that this adds an extra naming level to
Kimi's sample path.

Now, suppose someone does a GET on this URL:

  www.unitywave.com/testm/foo/post/username/filename.html

The program named /usr/local/apache/cgiprogs/foo
will be executed.  If you are using the usual
CGI module by Lincoln Stein, then the &path_info
function will return all after "foo", in this case
/post/username/filename.html.  (I'm not too sure if
you'll see the leading slash.)

To play with the path_info feature, you can
use my little toy CGI at:
  http://plug.unitywave.com/cgi-bin/cgi_test.pl

(Note that this strips any absolute-looking pathname
down to its final component, to demonstrate a
security policy.)

The source is at plug.unitywave.com/cgi_test

Vic
http://members.cox.net/vodhner/