I'm trying to puzzle out Apache handlers. The official documentation has the following example:
The following directives will cause requests for files with the html extension to trigger the launch of the footer.pl CGI script.
Action add-footer /cgi-bin/footer.pl
AddHandler add-footer .html
Then the CGI script is responsible for sending the originally requested document (pointed to by the PATH_TRANSLATED environment variable) and making whatever modifications or additions are desired.
I try to follow this example. My directory set up is:
- /var/www/testsite/index.html
- /var/www/testsite/cgi-bin/rp.sh
My virtual host file is:
<VirtualHost *:80>
ServerName http://localhost-testsite
DocumentRoot /var/www/testsite
<Directory /var/www/testsite>
Action footer /cgi-bin/rp.sh
AddHandler footer .html
</Directory>
ErrorLog /var/www/logs/error-testsite.log
</VirtualHost>
If I understood the documentation correctly, when an html file is requested, my rp.sh script should be called with PATH_TRANSLATED variable set to the html file name. However, when I open localhost-testsite/index.html in my browser, I get an unexpected error:
[Thu Mar 14 15:38:18 2013] [error] [client 127.0.0.1] File does not exist: /var/www/testsite/cgi-bin/rp.sh/index.html
Am I missing something? The most important question is: how can I make a cgi script process all files with a certain extension?
Apache version is Apache/2.2.22 (Ubuntu). All files and dirs have 777 permission.