You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Eric S. Johansson" <es...@harvee.org> on 2005/05/07 01:35:14 UTC

[users@httpd] invisible CGI invocation

I'm currently using 404 error handling to achieve this but what I'm 
looking to do is invoke multiple CGI programs depending on the base URL 
and everything after the base URL is passed to the CGI.  For example:

base URL
http://www.demo.org/

anything containing the base URL invokes the CGI program

http://www.demo.org/foo/rat

would invokes the base URL associated CGI program and pass the relative 
URL /foo/rat to the CGI program.  Currently I do this with an error 
document hack.  Works well just that every reference creates a 404 entry 
in the log.

but if I was to associate a different CGI with a different base URL but 
in the same hierarchy:

http://www.demo.org/alternative/

and any URL containing that base invokes the alternative CGI as well as 
passing the relative URL to CGI program.

I'm making it work now with <directory> and ErrorDocument handlers but 
it does seem like an awful hack.  I have tried using index.cgi but 
either I'm doing something wrong and it is not being invoked or it isn't 
right for this problem.

---eric


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


[users@httpd] Re: invisible CGI invocation

Posted by "Eric S. Johansson" <es...@harvee.org>.
Joshua Slive wrote:
> 
> This could be done in various ways, but given the potential
> complexity, you'll probably want to invest the time to learn
> mod_rewrite.  The basic config you discussed above would look
> something like:
...

> - You'll surely need to invest time in reading the mod_rewrite docs
> and investigating the RewriteLog if you want to use this.

thanks for this info.  It is much appreciated and I will look into it. 
based on some other research I've done, since the cgi is python based, 
mod_python may also be fruitful.  however in the short term, abusing the 
404 error handler is the easiest solution.

again many thanks.

--- eric


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


Re: [users@httpd] invisible CGI invocation

Posted by Joshua Slive <js...@gmail.com>.
On 5/6/05, Eric S. Johansson <es...@harvee.org> wrote:
> I'm currently using 404 error handling to achieve this but what I'm
> looking to do is invoke multiple CGI programs depending on the base URL
> and everything after the base URL is passed to the CGI.  For example:
> 
> base URL
> http://www.demo.org/
> 
> anything containing the base URL invokes the CGI program
> 
> http://www.demo.org/foo/rat
> 
> would invokes the base URL associated CGI program and pass the relative
> URL /foo/rat to the CGI program.  Currently I do this with an error
> document hack.  Works well just that every reference creates a 404 entry
> in the log.
> 
> but if I was to associate a different CGI with a different base URL but
> in the same hierarchy:
> 
> http://www.demo.org/alternative/
> 
> and any URL containing that base invokes the alternative CGI as well as
> passing the relative URL to CGI program.
> 
> I'm making it work now with <directory> and ErrorDocument handlers but
> it does seem like an awful hack.  I have tried using index.cgi but
> either I'm doing something wrong and it is not being invoked or it isn't
> right for this problem.

This could be done in various ways, but given the potential
complexity, you'll probably want to invest the time to learn
mod_rewrite.  The basic config you discussed above would look
something like:

RewriteEngine On
RewriteRule ^/alternative(.*) /full/path/to/alternative.cgi$1 [L]
RewriteRule ^/(.*) /full/path/to/regular.cgi/$1

A few notes:
- You'll probably need to configure those CGIs using AddHandler and
Options ExecCGI rather than ScriptAlias.
- This will really catch *every* request, including .gif/.jpg/.pdf/etc
- You'll surely need to invest time in reading the mod_rewrite docs
and investigating the RewriteLog if you want to use this.

Joshua.

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