Gossamer Forum
Home : General : Perl Programming :

Executing a Perl script with .htaccess

Quote Reply
Executing a Perl script with .htaccess
Is it possible to execute a Perl script using .htaccess? What I am trying to do is use .htaccess to execute a Perl script that will prompt a user for their username/password. This is a part of the script:



Code:


&authenticate("Basic", "Restricted Area");



...



sub authenticate {

local($authtype, $realm) = @_;

print "Status: 401 Authentication Required\n";

print "WWW-Authenticate: ".$authtype." realm=\"".$realm."\"\n" ;

$go = "http://www.mysite.com/members/index.html";

print "Location: $go\n\n";

exit(0) ;

}
Quote Reply
Re: [BennyHill] Executing a Perl script with .htaccess In reply to
>>
What I am trying to do is use .htaccess to execute a Perl script that will prompt a user for their username/password.
<<

Hmm could I ask what the point is?

Why don't you just send people to the restricted area and the password prompt will popup on its own Laugh
Quote Reply
Re: [Paul] Executing a Perl script with .htaccess In reply to
It's not quite that simple. Long story. Anyway, is it possible to do what I am after?
Quote Reply
Re: [BennyHill] Executing a Perl script with .htaccess In reply to
Hm. Interesting. I would try something like:

Code:
ErrorDocument 200 http://path/to/script

Although the code 200 is not specificllay an error, it is actually the code for "success" it might work - it might not.

I haven't tested this, but I'm just thinking of way to do this off the top of my head.

Other ways could be a Redirect, or a mod_rewrite rule.. maybe something like this:

Code:
AuthUserFile /dev/null
AuthGroupFile /dev/null

RewriteEngine On

RewriteRule /* http://path/to/script [R,L]

- wil

Last edited by:

Wil: May 18, 2002, 8:22 AM