Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
The stupid question is the question not asked
 
PerlMonks  

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)?

Comment on Ways for capturing all requests under Apache
Download Code
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,
    Zaxo

      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.
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?)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://380745]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-04-23 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (551 votes), past polls