Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Ways for capturing all requests under Apache

by sutch (Curate)
on Aug 06, 2004 at 21:54 UTC ( #380745=perlquestion: print w/replies, xml ) Need Help??
sutch has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking for options in capturing all HTTP requests to a host (or a specific directory of a host) by one script. The environment that I'm working in is Apache HTTP (version 1.3). Sometimes I'm able to use mod_perl, but for the most part I'm required to use CGI.

So far I've been able to make use of

ErrorDocument 404 /myapp/index.cgi

This works well, providing /myapp/index.cgi with all requests made to any path within the /myapp directory (such as /myapp/foo/bar).

The problem with this is that it fills up Apache's error log.

Are there other methods? If so, how does Perl get at the requested path (I've had problems with this when attempting to use mod_rewrite)?

Replies are listed 'Best First'.
Re: Ways for capturing all requests under Apache
by BUU (Prior) on Aug 06, 2004 at 22:16 UTC
    I think you want something along the lines of:
    <Directory /foo/bar> SetHandler "my_module" #SetPerlHandler ? </Directory>
      Thank you. The final snippet of .htaccess code that works for me turns out to be:

      Action my-handler /cgi-bin/index.cgi SetHandler my-handler

      And the requested path is available to the script in the PATH_INFO environment variable.

      UPDATE: For this to work, a file named index.cgi must be available in the same directory as the .htaccess file. The file may be empty or contain anything, since it is never executed. (Question: why is this file needed by Apache?)

Re: Ways for capturing all requests under Apache
by Zaxo (Archbishop) on Aug 06, 2004 at 22:08 UTC

    Are you looking for DirectoryIndex /cgi/foo.cgi in .htaccess? See the apache manual for its properties.

    After Compline,

      This only sets the name of the file that Apache will look for when a path is requested without a filename. If the directory does not exist, then an error document is returned.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://380745]
Approved by Old_Gray_Bear
[Corion]: Viewing Tk Colours (Colors) by name has the list of all Tk colour names

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-10-17 11:53 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (226 votes). Check out past polls.