Using mod_rewrite to mask /cgi-bin/abc as /def
- by Alois Mahdal
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>
<Directory "D:/opt/apache/cgi-bin/">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
(I know it's dumb but it's only a testing machine :D.)
Now, I have d:\opt\apache\cgi-bin\expired.pl 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 \expired.pl.
What I tried was setting following at the end of http.conf:
RewriteEngine on
RewriteRule ^/licensecheck.php$ /cgi-bin/expired.pl [T=application/x-httpd-cgi,L]
...but it keeps 404-ing me, looking for cgi-bin directory (not cgi-bin\expired.pl) in my DocumentRoot!
[error] [client 127.0.0.1] script not found or unable to stat: D:/opt/apache/htdocs/cgi-bin
/cgi-bin/expired.pl and all other scripts in /cgi-bin/ work as expected,
Only way I could make it work was actually putting the \expired.pl to DocumentRoot, but I don't want this, I want my cgi-bin neatly separated :)