Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite -> cgi = 403 Forbidden (without rewrite=works)

Options ExecCGI is off in this directory

         

openbsd

5:46 pm on Dec 26, 2009 (gmt 0)

10+ Year Member



hi folks,

I'm getting a headache on the following problem, using Apache 1.3:
Directory structure:
/var/www/domains/www.domain.net/htdocs
/var/www/domains/www.domain.net/logs
/var/www/domains/www.domain.net/cgi-bin

Important files reside here:
/var/www/domains/www.domain.net/cgi-bin/test.pl
/var/www/domains/www.domain.net/htdocs/test.txt

Please note: apache is chrooted in /var/www!

This is what I have as my virtual host configuration:

<VirtualHost *:80>
ServerName www.domain.net
DocumentRoot /domains/www.domain.net/htdocs
DirectoryIndex index.php index.html
ErrorLog /var/www/domains/www.domain.net/logs/error
CustomLog /var/www/domains/www.domain.net/logs/access combined
AddHandler cgi-script cgi pl
ScriptAlias /cgi-bin/ /var/www/domains/www.domain.net/cgi-bin/
<Directory /domains/www.domain.net/cgi-bin>
AllowOverride Options
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteRule ^/test\.txt$ /cgi-bin/test.pl [L,T=application/x-httpd-cgi]
</VirtualHost>

Does work: www.domain.net/cgi-bin/test.pl --> result of test.pl
Does NOT work: www.domain.net/test.txt --> 403 Forbidden
Error log: Options ExecCGI is off in this directory: /cgi-bin/test.pl

Why does this problem occur? Any ideas?

Thanks for your help. Merry Christmas!

jdMorgan

3:44 am on Dec 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried enabling ExecCGI in the root directory? The rewrite is 'making it appear' that the cgi code is being executed as /test.txt in the root directory, so if ExecCGI is off in that directory, it may not work...

Also, you might be happier (security-wise) using a second ScriptAlias instead of a rewrite to 'point' test.txt to the script.

Jim