redirect page: strange behaviour

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anja

    #1

    redirect page: strange behaviour

    Hi,

    At the end of one of my php pages, I have a statemtent
    echo "<meta http-equiv=\"refresh \" content=\"0; url=Master.php\ "> " ;
    which works well: it redirects to my page 'Master.php'.

    But, on some occasions, my browser (IE 6) wants to go to
    http:Master.php
    and hangs, giving the message 'Invalid syntax error'.

    I dont know in which case it has this behaviour. Anybody any clue?

    Thanks
    Anja
  • Dani CS

    #2
    Re: redirect page: strange behaviour

    Anja wrote:[color=blue]
    > Hi,
    >
    > At the end of one of my php pages, I have a statemtent
    > echo "<meta http-equiv=\"refresh \" content=\"0; url=Master.php\ "> " ;
    > which works well: it redirects to my page 'Master.php'.[/color]

    You should avoid this kind of redirect. It breaks the "Back" button on
    the user's browser.

    Use header("Locatio n: " . $absoluteUrl); inside your PHP code (remember
    to use it before anything that gets sent to the browser, such as <html>
    or even newlines).
    [color=blue]
    >
    > But, on some occasions, my browser (IE 6) wants to go to
    > http:Master.php
    > and hangs, giving the message 'Invalid syntax error'.[/color]

    Use an absolute url:

    <meta http-equiv="refresh"
    content="0;http ://www.yourserver. com/Master.php" />
    [color=blue]
    >
    > I dont know in which case it has this behaviour. Anybody any clue?[/color]

    Workarounds rather than clues.
    [color=blue]
    >
    > Thanks
    > Anja[/color]

    Comment

    • Sean

      #3
      Re: redirect page: strange behaviour

      On 7 Feb 2005 12:00:03 -0800, anjasmedts@hotm ail.com (Anja) reverently
      intoned upon the aether:
      [color=blue]
      > Hi,
      >
      > At the end of one of my php pages, I have a statemtent
      > echo "<meta http-equiv=\"refresh \" content=\"0; url=Master.php\ "> " ;
      > which works well: it redirects to my page 'Master.php'.
      >
      > But, on some occasions, my browser (IE 6) wants to go to
      > http:Master.php
      > and hangs, giving the message 'Invalid syntax error'.
      >
      > I dont know in which case it has this behaviour. Anybody any clue?
      >
      > Thanks
      > Anja[/color]

      It is doing what you told it to do. Instead, you should probably
      specify a hard coded domain name like:

      url=http://www.whereever.n et/Master.php

      Depending on implicit behavior like you have can create odd bugs.
      Whereas, if you explicitly code it, then you will not have any issues
      with the implicit behavior as you have had here.

      hope this helps,

      Sean



      "In the End, we will remember not the words of our enemies,
      but the silence of our friends."

      - Martin Luther King Jr. (1929-1968)

      Photo Archive @ http://www.tearnet.com/Sean
      Last Updated 29 Sept. 2004

      Comment

      • Anja

        #4
        Re: redirect page: strange behaviour

        > It is doing what you told it to do. Instead, you should probably[color=blue]
        > specify a hard coded domain name like:
        >
        > url=http://www.whereever.n et/Master.php
        >
        > Depending on implicit behavior like you have can create odd bugs.
        > Whereas, if you explicitly code it, then you will not have any issues
        > with the implicit behavior as you have had here.
        >
        > hope this helps,
        >
        > Sean[/color]

        First of all, thank you for your ideas.
        When it does what I told it to do, then what exactly does it? If in
        one case it's doing exactly as expected, going to Master.php, and in
        another case trying to go to an invalid page, WHAT tries this
        redirection to do?

        Using a complete path rather than a relative path is a solution, but
        not an ideal one. The path is different on my test server than the one
        on the net; if the root ever changes, I have to change hard coded
        redirections too...

        Using other redirection methods must be the first line send to the
        browser, which conflicts with the use of sessions.

        Anja.

        Comment

        • John Dunlop

          #5
          Re: redirect page: strange behaviour

          Anja wrote:
          [color=blue]
          > Using a complete path rather than a relative path is a solution, but
          > not an ideal one. The path is different on my test server than the one
          > on the net; if the root ever changes, I have to change hard coded
          > redirections too...[/color]

          Look, it's simple: Cool URIs don't change.

          http://www.w3.org/Provider/Style/URI

          ('Do as we say, not as we do.')
          [color=blue]
          > Using other redirection methods must be the first line send to the
          > browser, which conflicts with the use of sessions.[/color]

          Where's the trouble? There seems to be talk in the user-
          notes in the chapter on sessions about redirecting properly.



          --
          Jock

          Comment

          Working...