Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've noticed on some systems I will do a redirect with CGI and the address bar will reflect the redirect. On other systems the address bar does not update to reflect the URL change.

I mean that I am running the same code on different web servers when I say systems.

Is there any way to force the address bar to update?

Replies are listed 'Best First'.
Re: redirect does/does not change address
by merlyn (Sage) on Apr 30, 2005 at 16:09 UTC
    There are two kinds of redirects:
    use CGI qw(redirect); print redirect("http://www.your.server/some/page"); # external ## or print redirect("/some/page"); # internal
    An internal redirect is not visible to the browser. The webserver merely continues to "fetch" the requested URL using the newly replaced local part.

    An external redirect is sent immediately to the browser, asking the browser to refetch the new URL as if it was the original.

    Internal redirects do not update the browser location, and can be very confusing to relative included content (like IMG SRC="foo/bar.gif"). External redirects do update the browser location.

    They both have their uses, but you're in the driver seat about which one you need to use.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      I wonder if this actually answers OP's question, s?he's saying (bold is mine):
      I mean that I am running the same code on different web servers when I say systems.
      But your explaination is indeed interesting, I wouldn't wonder that. Does it apply to all webservers per some (de-facto) standard?

      Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

      Don't fool yourself.
Re: redirect does/does not change address
by ikegami (Patriarch) on Apr 30, 2005 at 16:23 UTC
    You might not see any changes in the address bar if the page being redirected is in a frame.
Re: redirect does/does not change address
by bradcathey (Prior) on Apr 30, 2005 at 18:27 UTC

    merlyn makes a great points. But I have another angle. I haven't seen your code, but have you printed the CGI header anywhere else in your code (like a cookie, e.g.)? You can only print it once per script. I've run into this myself so you might want to check out this recent node. I had some great replys.


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot