httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Christensen <dpchr...@holgerdanske.com>
Subject Re: [users@httpd] How htaccess enables CGI script as default page
Date Wed, 02 Mar 2011 23:47:46 GMT
On 03/02/2011 03:22 PM, Tim Johnson wrote:
> I'm attempting to use .htaccess to make an executable python script
> as the default page for a directory.

I recently wanted to have *all* hits for a particular subtree to go to a 
Perl CGI script on Debian 6.0.0 and Apache 2.2 via .htaccess.  The key 
was realizing that I could catch index hits via DirectoryIndex and "not 
found" hits via ErrorDocument 404.


I ended up with two files in my DocumentRoot:

     .htaccess
     handler.pl


Here is .htaccess:

     $ cat .htaccess
     Options +ExecCGI
     AddHandler cgi-script pl
     DirectoryIndex                   handler.pl
     ErrorDocument 404 /errordocument/handler.pl


Hits to http://example.com/ go to handler.pl, and REQUEST_URI is set 
accordingly.


Hits to http://example.com/somedynamicdoc.hmtl go to handler.pl, and 
REQUEST_URI, REDIRECT_REQUEST_METHOD, and REDIRECT_STATUS are set 
accordingly.


If someone knows the name of my instance script, that works too -- hits 
to http://example.com/handler.pl go to handler.pl, and REQUEST_URI is 
set accordingly.


HTH,

David




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message