By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,642 Members | 1,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

Redirect home page

P: n/a
I have a "new" homepage. How do I automatically direct clients to this new
home page, i.e. when clients enter "OldHomePage.php", they will
automatically be directed to "NewHomePage.php."

Thanks......

Bruce
Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a

"Bruce A. Julseth" <br*****@attglobal.net> wrote in message
news:3f********@news1.prserv.net...
I have a "new" homepage. How do I automatically direct clients to this new
home page, i.e. when clients enter "OldHomePage.php", they will
automatically be directed to "NewHomePage.php."

Thanks......

Bruce


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.php":
<?php
header("Location: NewHomePage.php");
?>

Note the presence of a space character between the colon and the file name
of the new file
Douglas Abernathy
Jul 17 '05 #2

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

Jul 17 '05 #3

P: n/a
"Bruce A. Julseth" <br*****@attglobal.net> wrote in message
news:3f********@news1.prserv.net...
I have a "new" homepage. How do I automatically direct clients to this new
home page, i.e. when clients enter "OldHomePage.php", they will
automatically be directed to "NewHomePage.php."

Thanks......

Bruce

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
Jul 17 '05 #4

P: n/a
"Jim Moseby" <no****@dontspam.me> wrote in message
news:vP********************@giganews.com...
"Bruce A. Julseth" <br*****@attglobal.net> wrote in message
news:3f********@news1.prserv.net...
I have a "new" homepage. How do I automatically direct clients to this new home page, i.e. when clients enter "OldHomePage.php", they will
automatically be directed to "NewHomePage.php."

Thanks......

Bruce

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


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

JM

Jul 17 '05 #5

P: n/a
Douglas Abernathy wrote:
You need to use the "header" function to send an HTML header line,
s/HTML header line/HTTP header/
which only works if it is sent prior to ANY HTML markup (even a space
character in the wrong place will trigger an error).
s/ANY HTML markup/any output/
File "OldHomePage.php":
<?php
header("Location: NewHomePage.php");
?>
The Location header field value must be "a single absolute URI"
(RFC2616, sec. 14.30), support for relative URIs notwithstanding.
Note the presence of a space character between the colon and the file name
of the new file


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
Jul 17 '05 #6

P: n/a
Dave Bell wrote:
You can use a javascript function that will do this with a timeout,
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?
you can then display a message if you wished.


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
Jul 17 '05 #7

P: n/a
Jim Moseby wrote:
echo "<META http-equiv='refresh' content='0;
URL=http://www.yournewpage.com'>";


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
Jul 17 '05 #8

P: n/a
On Fri, 24 Oct 2003 08:41:01 -0400, Jim Moseby wrote:

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

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.
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.