1

I have a FastCGI script which I want to every request to be redirect to it, no matter which URL. My current vhost configuration is the following:

<VirtualHost *:80>
        ServerName localhost
        FastCGIExternalServer /var/www/localhost/cgi-bin/ws -host 127.0.0.1:2000
        Alias / /var/www/localhost/cgi-bin/ws
        DocumentRoot /var/www/localhost/cgi-bin/
        <Directory /var/www/localhost/cgi-bin/>
                SetHandler fastcgi-script
                Options +ExecCGI
                Options +FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

If I open the URL http://localhost on my browser I successfully see the page rendered by the CGI script. But if I try any other page I get an error 404 page from Apache, which means that the request was not redirected to my CGI script.

I added the following .htaccess file inside /var/www/localhost/cgi-bin/ with the following mod_rewrite rules:

RewriteEngine On                                                                                                                                                                
RewriteCond %{REQUEST_FILENAME} -s [OR]                                                                                                                                          
RewriteCond %{REQUEST_FILENAME} -l [OR]                                                                                                                                          
RewriteCond %{REQUEST_FILENAME} -d                                                                                                                                               
RewriteRule ^.*$ - [NC,L]                                                                                                                                                        
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}wc [NC,L]

But now all I got is a Apache error 500 page and a warning inside Apache logs with the message:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

How can I solve this and correctly redirect every request to my FastCGI script?

1 Answer 1

1

I don't understand why, but it worked after I changed:

from

Alias / /var/www/localhost/cgi-bin/ws

to

Alias / /var/www/localhost/cgi-bin/

Also, I cleaned up my .htaccess just to make things more pretty (removed the check for existing files and directories):

RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}wc [NC,L]

If someone understand why it worked, please explain at the comments or somewhere else. I sincerely think that Apache configuration is either a huge mess, or is a lot above my understanding capabilities.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .