Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm porting a CGI application from an embedded web server to run under Apache. In the effort of changing the least amount required I'm trying to figure out how to configure Apache so any requests coming in go to my CGI program, which then will use the QueryString environmental variable to determine which file needs to be created.

I have Apache working now to where it will process my CGI file if it's requested directly i.e. localhost/cgi-bin/cgi_test.out

but I need to figure out how to get my application to be called whenever any file is requested:

localhost/ -> call my application with QueryString set to "" or "/"

localhost/thisFile -> call my application with QueryString set to "/thisFile"

etc.

I have been doing all of my configuration testing under /etc/apache2/sites-available/mysite, which has been enabled and the default disabled.

Thanks for any help.

I've tried the recommendation from here: http://serverfault.com/questions/56082/configure-apache-to-handle-all-requests-via-single-index-php but I keep getting circular redirects.

EDIT: I have tried a few different variations of mod-rewrite but they have not worked yet.

I have an index.cgi file under /usr/lib/cgi-bin (default location) and the default index.html under /var/www/. I've reverted everything back to default settings so I'm ready to start fresh with any new ideas.

share|improve this question
    
are you using mod-rewrite? if so, could you post your rewrite rules for debugging –  Roy Rico Mar 11 '10 at 17:26
    
As Roy said, mod_rewrite is the solution. –  Warner Mar 11 '10 at 17:37
add comment

1 Answer

up vote 1 down vote accepted

Are you averse to mod_rewrite? You could easily setup a RewriteRule like so:

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule ^(.*)$ /mycgi.cgi [L,E=QUERY_STRING:$1]
share|improve this answer
    
Where should I be putting this? What file? I'm slightly confused on the purposes for the different configuration files. I'm not opposed to mod_rewrite at all. –  user11888 Mar 11 '10 at 17:45
    
This would be in your Apache config, where it goes depends on your configuration, e.g. if this is for a single vhost it'd go in the configuration for the vhost. Documentation for mod_rewrite is available at httpd.apache.org/docs/2.0/mod/mod_rewrite.html –  Brandon Adams Mar 11 '10 at 18:24
1  
I finally got the rewrite rule to work, turns out by default the AllowOverride None is configured and must be commented out. –  user11888 Mar 11 '10 at 23:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.