You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Eli Shemer <ap...@netvision.net.il> on 2007/10/06 13:11:03 UTC

redirect

Hey there,

I constructed a logout button which simply refers you to a page that takes
away your cookie and then redirects you the main page.

Internal_redirect however does not seem to be the best use in this case
since, apparently, the address bar is not updated accordingly and even the
cookie is not taken into account yet(I have to refresh the main page
"again")

 

One possible option might be porting Apache::Request::Redirect to mod_perl2
but I wanted to hear more suggestions if possible.

Preferrebly not using mod_rewrite or modifying any other apache
configuration.

 

Thanks all.


RE: redirect

Posted by Eli Shemer <ap...@netvision.net.il>.
I don't know if it's any help to anyone but if it is,
it seems the reason the usual redirect didn't work for me as it should, was
due to screen output after the redirect command

  $r->headers_out->set(Location => '../index.pl');
  $r->status(Apache2::Const::REDIRECT);
  $r->headers_out;

 # Print qq ( test ); # not a good idea 


-----Original Message-----
From: pharkins@gmail.com [mailto:pharkins@gmail.com] On Behalf Of Perrin
Harkins
Sent: Sunday, October 07, 2007 12:41 AM
To: Eli Shemer
Cc: Issac Goldstand; modperl@perl.apache.org
Subject: Re: redirect

On 10/6/07, Eli Shemer <ap...@netvision.net.il> wrote:
> $r->headers_out->set("Refresh"=>"0;url=index.pl");
>
> $r->headers_out;
> return Apache2::Const::OK;
>
> this method seems to be the best solution for me since
> 1. it works
> 2. I rather send an OK signal since it's not an actual warning/error but a
> valid redirect as part of the system.

There's no reason to avoid using a normal redirect in this case.  It's
not an error and will not be written to the error_log.  I'm not sure
all browsers will honor this trick you're using, but they definitely
will work with a standard 302 response.

- Perrin



Re: redirect

Posted by Perrin Harkins <pe...@elem.com>.
On 10/6/07, Eli Shemer <ap...@netvision.net.il> wrote:
> $r->headers_out->set("Refresh"=>"0;url=index.pl");
>
> $r->headers_out;
> return Apache2::Const::OK;
>
> this method seems to be the best solution for me since
> 1. it works
> 2. I rather send an OK signal since it's not an actual warning/error but a
> valid redirect as part of the system.

There's no reason to avoid using a normal redirect in this case.  It's
not an error and will not be written to the error_log.  I'm not sure
all browsers will honor this trick you're using, but they definitely
will work with a standard 302 response.

- Perrin

RE: redirect

Posted by Eli Shemer <ap...@netvision.net.il>.
$r->headers_out->set("Refresh"=>"0;url=index.pl");

$r->headers_out;
return Apache2::Const::OK;                     

this method seems to be the best solution for me since
1. it works
2. I rather send an OK signal since it's not an actual warning/error but a
valid redirect as part of the system.

Thanks a lot. 

-----Original Message-----
From: Issac Goldstand [mailto:margol@beamartyr.net] 
Sent: Saturday, October 06, 2007 7:02 PM
To: Eli Shemer
Cc: modperl@perl.apache.org
Subject: Re: redirect

Sounds like you're doing something not-quite-right...  A 302 status code
in conjunction with a Location header should immediately redirect to the
URL in the Location header.

If you'd rather, you can try sending a normal 200 (OK) response with an
empty HTML page, and a Refresh header (something like [mp1 code, but you
should get the idea]):
    $r->header_out("Refresh"=>"0;url=http://www.mydomain.com/");
    $r->send_http_header("text/html");
    $r->print("<HTML></HTML>");
)

  Issac

Eli Shemer wrote:
> I have previously have done this but instead of actually automatically
> referring me, it displayed an error with a link that "the paged has moved"
> or something of that sort.
> 
> 
> -----Original Message-----
> From: Issac Goldstand [mailto:margol@beamartyr.net] 
> Sent: Saturday, October 06, 2007 6:15 PM
> To: Eli Shemer
> Cc: modperl@perl.apache.org
> Subject: Re: redirect
> 
> Send a Location: header back instead of a full response and return
> HTTP_MOVED_TEMPORARILY from your handler.
> 
> If you want/need to return a response from the page, you can
> alternatively use an HTML META tag in the header to accomplish the same
> effect.
> 
>   Issac
> 
> Eli Shemer wrote:
>> Hey there,
>>
>> I constructed a logout button which simply refers you to a page that
>> takes away your cookie and then redirects you the main page.
>>
>> Internal_redirect however does not seem to be the best use in this case
>> since, apparently, the address bar is not updated accordingly and even
>> the cookie is not taken into account yet(I have to refresh the main page
>> "again")
>>
>>  
>>
>> One possible option might be porting Apache::Request::Redirect to
>> mod_perl2 but I wanted to hear more suggestions if possible.
>>
>> Preferrebly not using mod_rewrite or modifying any other apache
>> configuration.
>>
>>  
>>
>> Thanks all.
>>
> 



Re: redirect

Posted by Issac Goldstand <ma...@beamartyr.net>.
Sounds like you're doing something not-quite-right...  A 302 status code
in conjunction with a Location header should immediately redirect to the
URL in the Location header.

If you'd rather, you can try sending a normal 200 (OK) response with an
empty HTML page, and a Refresh header (something like [mp1 code, but you
should get the idea]):
    $r->header_out("Refresh"=>"0;url=http://www.mydomain.com/");
    $r->send_http_header("text/html");
    $r->print("<HTML></HTML>");
)

  Issac

Eli Shemer wrote:
> I have previously have done this but instead of actually automatically
> referring me, it displayed an error with a link that "the paged has moved"
> or something of that sort.
> 
> 
> -----Original Message-----
> From: Issac Goldstand [mailto:margol@beamartyr.net] 
> Sent: Saturday, October 06, 2007 6:15 PM
> To: Eli Shemer
> Cc: modperl@perl.apache.org
> Subject: Re: redirect
> 
> Send a Location: header back instead of a full response and return
> HTTP_MOVED_TEMPORARILY from your handler.
> 
> If you want/need to return a response from the page, you can
> alternatively use an HTML META tag in the header to accomplish the same
> effect.
> 
>   Issac
> 
> Eli Shemer wrote:
>> Hey there,
>>
>> I constructed a logout button which simply refers you to a page that
>> takes away your cookie and then redirects you the main page.
>>
>> Internal_redirect however does not seem to be the best use in this case
>> since, apparently, the address bar is not updated accordingly and even
>> the cookie is not taken into account yet(I have to refresh the main page
>> "again")
>>
>>  
>>
>> One possible option might be porting Apache::Request::Redirect to
>> mod_perl2 but I wanted to hear more suggestions if possible.
>>
>> Preferrebly not using mod_rewrite or modifying any other apache
>> configuration.
>>
>>  
>>
>> Thanks all.
>>
> 

RE: redirect

Posted by Eli Shemer <ap...@netvision.net.il>.
I have previously have done this but instead of actually automatically
referring me, it displayed an error with a link that "the paged has moved"
or something of that sort.


-----Original Message-----
From: Issac Goldstand [mailto:margol@beamartyr.net] 
Sent: Saturday, October 06, 2007 6:15 PM
To: Eli Shemer
Cc: modperl@perl.apache.org
Subject: Re: redirect

Send a Location: header back instead of a full response and return
HTTP_MOVED_TEMPORARILY from your handler.

If you want/need to return a response from the page, you can
alternatively use an HTML META tag in the header to accomplish the same
effect.

  Issac

Eli Shemer wrote:
> Hey there,
> 
> I constructed a logout button which simply refers you to a page that
> takes away your cookie and then redirects you the main page.
> 
> Internal_redirect however does not seem to be the best use in this case
> since, apparently, the address bar is not updated accordingly and even
> the cookie is not taken into account yet(I have to refresh the main page
> "again")
> 
>  
> 
> One possible option might be porting Apache::Request::Redirect to
> mod_perl2 but I wanted to hear more suggestions if possible.
> 
> Preferrebly not using mod_rewrite or modifying any other apache
> configuration.
> 
>  
> 
> Thanks all.
> 



Re: redirect

Posted by Issac Goldstand <ma...@beamartyr.net>.
Send a Location: header back instead of a full response and return
HTTP_MOVED_TEMPORARILY from your handler.

If you want/need to return a response from the page, you can
alternatively use an HTML META tag in the header to accomplish the same
effect.

  Issac

Eli Shemer wrote:
> Hey there,
> 
> I constructed a logout button which simply refers you to a page that
> takes away your cookie and then redirects you the main page.
> 
> Internal_redirect however does not seem to be the best use in this case
> since, apparently, the address bar is not updated accordingly and even
> the cookie is not taken into account yet(I have to refresh the main page
> "again")
> 
>  
> 
> One possible option might be porting Apache::Request::Redirect to
> mod_perl2 but I wanted to hear more suggestions if possible.
> 
> Preferrebly not using mod_rewrite or modifying any other apache
> configuration.
> 
>  
> 
> Thanks all.
>