views:

52

answers:

1

Trying to get a simple test perl script working. Have the following files/folder structure on a shared hosting service:

~/public_html/

  • .htaccess

~/public_html/lookup Permissions: "drwxrwxrwx 2 myusername myusername"

  • .htaccess
  • lookup.pl* Permissions: "-rwxr-xr-x myusername myusername"

The first .htaccess contains:

# disable directory browsing
Options All -Indexes

RewriteEngine on
RewriteBase /
RewriteRule ^(r)$ $1/ [R]
RewriteRule ^(r)/(.*)(\.[a-z]+)$ redirect.php?$1 [L]
RewriteRule ^(r)/(.*)$ redirect.php?$1 [L]

The second .htaccess contains:

RewriteEngine On
RewriteBase /lookup

RewriteCond %{REQUEST_URI} !^/lookup/lookup.pl [NC]
RewriteCond %{REQUEST_URI} !\.(css|png|jpg|gif)$ [NC]
RewriteRule ^(.*)$ lookup.pl/$1 [QSA,NC]

But direct access to: www.mysite.com/lookup/lookup.pl does not work and shows a "500 Internal Server Error"

A: 

Just a rough guess, because I don't know your complete configuration: Are you running the site under suEXEC (having a VirtualHost with User or Group directives in it)?

In that case you cannot run the script because the directory it's stored in is world-writable, which suEXEC does not like, and no error message is shown in the error_log (as Mike pointed out, the error message you provided does not relate to the real error, but to an error presenting a correct error page to you), but in the suexec_log which most people normally do not consult.

Jonas
Hi JOnas - this is on a shared hosting account...
RubiCon10
In that case you are _likely_ running under suEXEC because that's more or less a standard for running CGI in shared hosting. Please fix the permissions of the "lookup" directory from 777 (rwxrwxrwx) to 755 (rwxr-xr-x).
Jonas
Shoot me... the error was because these were actually TWO lines (but should have been THREE)... (LINE1)#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); (LINE2)print "Content-type: text/html\n\n";
RubiCon10
I'll accept your answer as you really did try to help me out here!
RubiCon10