You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Martin Haase-Thomas <mh...@meome-ag.de> on 2002/02/06 14:47:15 UTC
mod_perl & Redirect
Hi all,
I hope there'll be someone here to help we with a mod_perl prob, of
which I thought first it wouldn't be one. I refer to the "Writing Apache
Modules" book by Stein/MacEachern.
The prob is quite simple: I have to redirect certain requests under
certain conditions to another URL (and please believe me: I tried with
mod_rewrite, this way seems to be more efficient). I'm using Apache
1.13.22 on Debian Linux 2.4.17.
These are the lines from my httpd.conf:
PerlFreshRestart On
PerlTaintCheck On
PerlSetEnv SHORTNAMES /etc/apache/shortnames.txt
PerlAddVar PROJECT_DOCUMENT_ROOT /home/disp05/app/fn/
PerlRequire /usr/local/sbin/appstart
# apply shortnames mapping and serve static files:
<Location />
SetHandler perl-script
PerlHandler Apache::StaticServer
</Location>
The stanza in StaticServer.pm that fails is:
if ($redirect = $shortnames->get($fname, WAIT, 1)) {
if ($redirect !~ /$r->server()->server_hostname/) {
$r->content_type('text/html');
$r->header_out ( Location => $redirect ); $log->debug($redirect);
return REDIRECT;
}
...
}
$shortnames is an Apache::SharedMem segment, containing a vast amount of
shortnames as keys and the corresponding URLs as values. The funny thing
is now, that although I do everything exactly as I find it in the book
on p.125 (content_type, header_out, REDIRECT), I get pure nonsense.
This is what a libwww-perl client displays when I try to access the address:
500 (Internal Server Error) unexpected EOF before status line seen
Client-Date: Wed, 06 Feb 2002 13:40:25 GMT
This is what I find in access_log:
192.168.255.75 - - [06/Feb/2002:14:46:24 +0100] "GET /psycho HTTP/1.0"
200 - "-" "libwww-perl/5.50"
And this is what stands in error_log:
[Wed Feb 6 14:46:24 2002] [debug]
/usr/local/share/perl/5.6.1/Apache/StaticServer.pm(45): [client
192.168.255.75] http://www.domain.de/app/fn/portal_welcome_jsp/52329.html
The error log proves that the second if() matches, as the entry comes
from my $log->debug(...).
Has anyone got an idea? I'm close to depression -;)
Many thanx in advance
Martin
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org