This is a follow up for this question Apache directory directive authentication based on Perl CGI::Session
Alias /files /myData/all
<Directory /myData/all >
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ cgi-bin/checklogin.pl?url=/files/$1 [L,R]
Options +Indexes
</Directory>
/files is a directory listing.
I edited the directive so that if a user goes to webserver/files/ they are redirected to checklogin.pl which checks for the existance of a session. If there is one it should redirect to the ?url if not it takes them to the loginpage.
The first part works. The redirect to $url causes a loop.
my $url = $cgi->param("url");
my $cookie = $cgi->cookie('mysession');
if(!$cookie){
$session = new CGI::Session();
print $session->redirect('/loginpage.html');
}else{
# HOW DO I display folder or files now?
$session = new CGI::Session(undef, $cookie, {Directory=>'/tmp/'});
print $session->redirect($url);
}
I am, obviously, getting a redirect loop error in Apache
This webpage has a redirect loop