Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a seemingly easy task, but somehow I just can't get it to work:

Some interesting lines from my httpd.conf:

DocumentRoot "D:/opt/apache/htdocs"
ScriptAlias /cgi-bin/ "D:/opt/apache/cgi-bin/"
<Directory "D:/opt/apache/htdocs">
   Options Indexes FollowSymLinks ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
<Directory "D:/opt/apache/cgi-bin/">
    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from all

(I know it's dumb but it's only a testing machine :D.)

Now, I have d:\opt\apache\cgi-bin\ and I expect GET /licensecheck.php?code=123456. And I wish to fake client into thinking it speaks with /licensecheck.php, but actually return data by \

What I tried was setting following at the end of http.conf:

RewriteEngine on
RewriteRule ^/licensecheck.php$ /cgi-bin/ [T=application/x-httpd-cgi,L]

...but it keeps 404-ing me, looking for cgi-bin directory (not cgi-bin\ in my DocumentRoot!

[error] [client] script not found or unable to stat: D:/opt/apache/htdocs/cgi-bin
  • /cgi-bin/ and all other scripts in /cgi-bin/ work as expected,

  • Only way I could make it work was actually putting the \ to DocumentRoot, but I don't want this, I want my cgi-bin neatly separated :)

share|improve this question
1. Do you have a Directory directive for "D:/opt/apache/cgi-bin/" with permission set correctly? 2. Where did you put the RewriteEngine on et alli? – Chris S Jul 12 '11 at 17:49
Try [PT] flag: – LazyOne Jul 12 '11 at 20:17
@ChrisS: Updated according to your questions – Alois Mahdal Jul 12 '11 at 20:20
@LazyOne: Thanks, that actually works! Seems that I misunderstood mod_rewrite--i thought that was taken as URI. Thanks again all yoou guys! – Alois Mahdal Jul 12 '11 at 20:26
@AloisMahdal Please answer to your question, and check it as "Ok". – Olivier Pons Nov 14 '11 at 21:14
up vote 3 down vote accepted

The problem was just a misunderstanding; I thought that the subject for rewrite is implicitly taken as URI.

Adding [PT] changed the behavior, which solved my problem:

RewriteRule ^/licensecheck.php$ /cgi-bin/ [T=application/x-httpd-cgi,L,PT]
share|improve this answer

Your Answer


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.