Re: mod_perl and mod_rewrite can work together ?

"Hibbard, Timothy" <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CB46BBD0.10B6%[email protected]>
I do not use the httpd.conf to redirect instead I use the following code:


use Apache2::Const qw(HTTP_MOVED_TEMPORARILY);

$r->headers_out->add(Location => "http://someplace.come/index.html?iphone=yes");
$r->status( HTTP_MOVED_TEMPORARILY);
return HTTP_MOVED_TEMPORARILY;

From: Idel Fuschini <[email protected]<mailto:[email protected]>>
Date: Thu, 26 Jan 2012 07:02:09 -0500
To: modperl List <[email protected]<mailto:[email protected]>>
Subject: mod_perl and mod_rewrite can work together ?

I've got this issue, in httpd.conf:

PerlTransHandler +Apache2::MyRedirect
RewriteRule ^/$     /home/index.html [R=301]

my mod_perl2 module in some condition need to redirect the browser to another site. But my web server ignored my module.

This is the code:

 use Apache2::RequestRec ();
  use Apache2::RequestUtil ();
  use Apache2::SubRequest ();
  use Apache2::Log;
  use Apache2::Filter ();
  use APR::Table ();
  use LWP::Simple;
  use Apache2::Const -compile => qw(OK REDIRECT DECLINED);
sub handler    {
    my $f = shift;
    my $return_value=Apache2::Const::DECLINED;
    my $user_agent=lc($f->headers_in->{'User-Agent'}|| '');
    if ($user_agent =~ m/iphone/i) {
        $f->headers_out->set(Location => $location);
$f->status(Apache2::Const::REDIRECT);
$return_value=Apache2::Const::REDIRECT;
    }
    return $return_value;
  }

What is wrong, it's possible to do  ?

thanks
Idel
=====================
E-Mail: [email protected]<mailto:[email protected]>
Web Site: http://www.idelfuschini.it
AMF project:  http://www.apachemobilefilter.org
AMF wiki: Apache Mobile Filter - http:/wiki.apachemobilefilter.org<http://wiki.apachemobilefilter.org>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.