SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2003
    Location
    Earth
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help. images in cgi-bin -- how to setup it?

    Just got a new dedicated box with cpanel for my friend.

    His previous host allow him to put any .gif and .jpg files into a cgi-bin dir and browse it just fine through http://hisdomain.com/cgi-bin/files/image.jpg

    But in this new box if, he put any files into a cgi-bin dir and browse it through http://hisdomain.com/cgi-bin/files/image.jpg, the server will execute it as a script. Thus the result is 500 internal server error.

    My questions is how to set the httpd.conf file or set a .htaccess file so the server will not execute the image files which reside into a cgi-bin dir as a script?

    Thanks in advance.

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bizantium
    Just got a new dedicated box with cpanel for my friend.

    His previous host allow him to put any .gif and .jpg files into a cgi-bin dir and browse it just fine through http://hisdomain.com/cgi-bin/files/image.jpg

    But in this new box if, he put any files into a cgi-bin dir and browse it through http://hisdomain.com/cgi-bin/files/image.jpg, the server will execute it as a script. Thus the result is 500 internal server error.

    My questions is how to set the httpd.conf file or set a .htaccess file so the server will not execute the image files which reside into a cgi-bin dir as a script?

    Thanks in advance.
    Hi,
    I think that you used the ScriptAlias inside your httpd.conf.
    The ScriptAlias allows all files to be executed as cgi,
    and AFAIK once ScriptAlias is enabled there is no way to go back.

    So my solution is to:
    a) comment the scriptalias directive line (ie disable it)
    b) use something like this:
    Code:
        # document root is c:/usr/www/mytest.net/htdocs
    
        Alias /cgi-bin/ "c:/usr/www/mytest.net/cgi-bin/"
    
        <Directory "c:/usr/www/mytest.net/cgi-bin">
            # Allow CGI execution only for files with .cgi and .pl extensions
            AddHandler cgi-script cgi pl
            # Do not allow .htaccess files
            AllowOverride None
            # Allow CGI execution inside this directory and following
            Options +ExecCGI
            Order allow,deny
            Allow from all
        </Directory>
    so basically
    /domain.com/cgi-bin/pippo.pl
    /domain.com/cgi-bin/files/pippo.pl
    will executed as a CGI

    while
    /domain.com/cgi-bin/pippo.gif
    /domain.com/cgi-bin/files/pippo.gif
    won't be executed as a CGI


    :-) pippo
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •