We're establishing an API and you want to use Apache mod_rewrite to direct all accesses to http://api.domain.com towards the script situated at /cgi-bin/api.pl. Here's what we are presently using:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^api.domain.com$ [NC]
RewriteRule ^(.*)$ /cgi-bin/api.pl [NC,L,QSA]

However, this really is giving us the next error:

[Fri Sep 03 14:18:32 2010] [error] [client] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
[Fri Sep 03 14:18:32 2010] [error] [client] 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.

When we attempt to access http://domain.com/cgi-bin/api.pl the script functions correctly. What exactly are we doing wrong? Help! Thanks ahead of time.

I suppose that you are determining your rules inside a .htaccess file, in which the L flag might not work like you were expecting.

As your test pattern ^(.*)$ matches whatever input is offered into it, the URL you rewrite to can also be matched up around the subsequent request, and also you have an internal infinite redirection loop (resulting eventually within the server error).

An answer would be to determine if you have rewritten the URL:

RewriteEngine on

RewriteCond %{REQUEST_URI} !=/cgi-bin/api.pl
RewriteCond %{HTTP_HOST} ^api.domain.com$ [NC]
RewriteRule ^.*$ /cgi-bin/api.pl [NC,L,QSA]