Dirk Lutzebaeck wrote:
> ie.
>
> <Location /PERL>
> Options ExecCGI
> SetHandler perl-script
> PerlHandler Apache::OutputChain Apache::GzipChain Apache::Registry
> </Location>
>
> and /PERL/x.pl
>
> use Apache;
> use Apache::Constants qw(REDIRECT);
> $r = Apache->request;
> $r->header_out("Location" => "/y.html");
> $r->status(REDIRECT);
>
> this works.

Is it legal to issue a redirect header relative to the server base? I didn't
think you were allowed to do that, so I was using this function to get a
reference back to the specific ipaddr/port on the server:

use Socket qw();
sub self_referential_host
{
    my $r = shift;
    my $host = $r->header_in("Host");
    if ( not defined $host ) {
        my ($port, $ipaddr_bin) = Socket::unpack_sockaddr_in
$r->connection->local_addr;
        my $ipaddr = Socket::inet_ntoa $ipaddr_bin;
        $host = "$ipaddr" . ( $port == 80 ? "" : ":$port" );
    }
    return $host;
}

Can I really just do a "Location: /auth/" and have it work?

 - David Harris
   Principal Engineer, DRH Internet Services

Reply via email to