Redirect home page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bruce A. Julseth

    #1

    Redirect home page

    I have a "new" homepage. How do I automatically direct clients to this new
    home page, i.e. when clients enter "OldHomePage.ph p", they will
    automatically be directed to "NewHomePage.ph p."

    Thanks......

    Bruce


  • Douglas Abernathy

    #2
    Re: Redirect home page


    "Bruce A. Julseth" <bruceaj@attglo bal.net> wrote in message
    news:3f989d87_3 @news1.prserv.n et...[color=blue]
    > I have a "new" homepage. How do I automatically direct clients to this new
    > home page, i.e. when clients enter "OldHomePage.ph p", they will
    > automatically be directed to "NewHomePage.ph p."
    >
    > Thanks......
    >
    > Bruce
    >
    >[/color]

    You need to use the "header" function to send an HTML header line, which
    only works if it is sent prior to ANY HTML markup (even a space character in
    the wrong place will trigger an error).

    File "OldHomePage.ph p":
    <?php
    header("Locatio n: NewHomePage.php ");
    ?>

    Note the presence of a space character between the colon and the file name
    of the new file
    Douglas Abernathy


    Comment

    • Dave Bell

      #3
      Re: Redirect home page

      You can use a javascript function that will do this with a timeout, you
      can then display a message if you wished.

      Comment

      • Jim Moseby

        #4
        Re: Redirect home page

        "Bruce A. Julseth" <bruceaj@attglo bal.net> wrote in message
        news:3f989d87_3 @news1.prserv.n et...[color=blue]
        > I have a "new" homepage. How do I automatically direct clients to this new
        > home page, i.e. when clients enter "OldHomePage.ph p", they will
        > automatically be directed to "NewHomePage.ph p."
        >
        > Thanks......
        >
        > Bruce[/color]


        Put this anywhere in your PHP on the old page, change content= to the number
        of seconds you want to wait before redirecting.:

        echo "<META http-equiv='refresh' content='0;
        URL=http://www.yournewpage .com'>";


        HTH - JM


        Comment

        • Jim Moseby

          #5
          Re: Redirect home page

          "Jim Moseby" <nospam@dontspa m.me> wrote in message
          news:vPednexwfL 0QgQSiU-KYvA@giganews.c om...[color=blue]
          > "Bruce A. Julseth" <bruceaj@attglo bal.net> wrote in message
          > news:3f989d87_3 @news1.prserv.n et...[color=green]
          > > I have a "new" homepage. How do I automatically direct clients to this[/color][/color]
          new[color=blue][color=green]
          > > home page, i.e. when clients enter "OldHomePage.ph p", they will
          > > automatically be directed to "NewHomePage.ph p."
          > >
          > > Thanks......
          > >
          > > Bruce[/color]
          >
          >
          > Put this anywhere in your PHP on the old page, change content= to the[/color]
          number[color=blue]
          > of seconds you want to wait before redirecting.:
          >
          > echo "<META http-equiv='refresh' content='0;
          > URL=http://www.yournewpage .com'>";
          >
          >
          > HTH - JM[/color]

          Correction, this needs to appear in between the <head> </head> tags in the
          HTML.

          JM



          Comment

          • John Dunlop

            #6
            Re: Redirect home page

            Douglas Abernathy wrote:
            [color=blue]
            > You need to use the "header" function to send an HTML header line,[/color]

            s/HTML header line/HTTP header/
            [color=blue]
            > which only works if it is sent prior to ANY HTML markup (even a space
            > character in the wrong place will trigger an error).[/color]

            s/ANY HTML markup/any output/
            [color=blue]
            > File "OldHomePage.ph p":
            > <?php
            > header("Locatio n: NewHomePage.php ");
            > ?>[/color]

            The Location header field value must be "a single absolute URI"
            (RFC2616, sec. 14.30), support for relative URIs notwithstanding .
            [color=blue]
            > Note the presence of a space character between the colon and the file name
            > of the new file[/color]

            That space character isn't mandatory (RFC2616, sec. 4.2), although
            it is "preferred" , and such usage is well-established insofar as
            it's been adopted by the HTTP standard itself. In fact, any amount
            of linear white space (LWS) is permitted before a header field
            value. However, semantically speaking, all LWS is equivalent to a
            single space (RFC2616, sec. 2.2).

            Just for completeness:

            CR = <US-ASCII CR, carriage return (13)>
            LF = <US-ASCII LF, linefeed (10)>
            SP = <US-ASCII SP, space (32)>
            HT = <US-ASCII HT, horizontal-tab (9)>
            CRLF = CR LF
            LWS = [CRLF] 1*( SP | HT )

            Elucidating for the ABNF-challenged amongst us, LWS translates to:
            an optional carriage-return linefeed sequence, aka "end-of-line
            marker", followed by one or more spaces or horizontal-tabs.

            --
            Jock

            Comment

            • John Dunlop

              #7
              Re: Redirect home page

              Dave Bell wrote:
              [color=blue]
              > You can use a javascript function that will do this with a timeout,[/color]

              Do what?

              Anyhow, what if Javascript isn't available or enabled? What if the
              "timeout" doesn't give users time to read and process the
              information you'll assumably present to them?
              [color=blue]
              > you can then display a message if you wished.[/color]

              A good point.

              If you wish to tell users something, such as informing them about
              the new URL, then providing a message and a link to the new
              document is sufficient; indeed, this method greatly surpasses
              sufficiency -- it is superior.

              --
              Jock

              Comment

              • John Dunlop

                #8
                Re: Redirect home page

                Jim Moseby wrote:
                [color=blue]
                > echo "<META http-equiv='refresh' content='0;
                > URL=http://www.yournewpage .com'>";[/color]

                Contextually, employing such a pseudo redirect is irresponsible.
                The world shall be a better place when mainstream browsers allow
                users to seamlessly follow veritable redirects whilst ignoring
                those bogosities.

                ObPHP: seeing as there're no variables or escape sequences, your
                string ought to be quoted with single-quotes, if you really must
                echo it at all.

                --
                Jock

                Comment

                • The Graphical Gnome

                  #9
                  Re: Redirect home page

                  On Fri, 24 Oct 2003 08:41:01 -0400, Jim Moseby wrote:
                  [color=blue]
                  >
                  > echo "<META http-equiv='refresh' content='0;
                  > URL=http://www.yournewpage .com'>";
                  >[/color]
                  If you have a delay of zero seconds as you are seeing more and more on teh
                  net. It will give the user a hard time using the BACK option on the
                  browser.

                  Never use this F&*&^ posibility.


                  Comment

                  Working...