How do I get Apache to execute a CGI script in the middle of a URL?

1. You'll have to enable mod_rewrite for Apache and figure out how
to create
the appropriate url rewriting rules (basically, regular
expressions)....

2. We use a bunch of URL rewrite rules to solve this issue....

3. One way to deal with this is using rewriting rules but IMHO
there is a cleaner solution to this, which is something we have
used in the past. Keep your mylibrary CGI in your favorite
location, and then attach a custom handler to it, using the
following paradigm:

  <Location /mylibrary>
    SetHandler mylibrary-handler
    Action mylibrary-handler /cgi-bin/mylibrary.pl virtual
  </Location>

(here I assume that your cgi script is at
http://example.com/cgi-bin/mylibrary.pl).  Using this setup, any
URL that starts with /mylibrary will cause apache to call your
cgi script, with the proper path_info filled in.  A similar
approach is to have the script actually reside in /mylibrary but
declare it as such by mapping the /mylibrary url to the cgi
handler, but I find the above approach cleaner since you don't
have to mix your scripts and docs.  See the apache docs for more
details.


Thank you for the prompt replies.

Counting a previous message, there were three "votes" for using
mod_rewrite and one vote for the use of an Action handler. Like Perl,
there seems to be more than one way to do it. I have initially played
with the handler technique and have had some success. Now I have to
go back to the RESTful manual and see about turning my content into
"resources". 'More later, maybe much later.

--
Eric Lease Morgan
University Libraries of Notre Dame

Reply via email to