FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » how do I create a redirect in a php file
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
how do I create a redirect in a php file [message #6629] Sat, 19 October 2002 00:16 Go to next message
esm2002 is currently offline  esm2002   United States
Messages: 339
Registered: May 2002
Location: Atlanta Georgia
Karma: 0
Senior Member
how do I create an index.php page with the following redirect in it?

<META HTTP-EQUIV=REFRESH CONTENT="8;URL=http://www.mysite.com/fudforum/br/index.php">


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Re: how do I create a redirect in a php file [message #6630 is a reply to message #6629] Sat, 19 October 2002 01:26 Go to previous messageGo to next message
valiant is currently offline  valiant   Switzerland
Messages: 80
Registered: September 2002
Location: Zurich
Karma: 0
Member
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<titleyour title</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta HTTP-EQUIV=Refresh Content="8; URL=http://<?php echo 
                  $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']?>">
</head>
<body>
</body>
</html>



i guess you want somehting different: http://www.php.net/manual/en/function.header.php

[Updated on: Sat, 19 October 2002 01:27]

Report message to a moderator

Re: how do I create a redirect in a php file [message #6633 is a reply to message #6629] Sat, 19 October 2002 15:52 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You want the page to be reloaded every 8 seconds?

Or what exactly are you trying to do?


FUDforum Core Developer
Re: how do I create a redirect in a php file [message #6648 is a reply to message #6629] Sun, 20 October 2002 23:14 Go to previous messageGo to next message
esm2002 is currently offline  esm2002   United States
Messages: 339
Registered: May 2002
Location: Atlanta Georgia
Karma: 0
Senior Member
sorry about not being clear on what I was looking for.

I have ocasssionaly had to move a page from one folder to another. When I have have done that in the past, I just replaced the original index.htm file with an index.htm file that had the following:

<!doctype HTML public "-//w3c//dtd HTML 4.0 transitional//en">
<HTML>
<HEAD>
<META HTTP-EQUIV=REFRESH CONTENT="8;URL=http://www.mysite.com/members.html">
</HEAD>
<BODY>
<P>&nbsp;</P><P>&nbsp;</P>
<CENTER>
<FONT SIZE="2" COLOR="1600A5" FACE=VERDANA><B>
You will automatically be redirected to the Message boards.
<BR><BR>
Or click the link if you can't wait!!!
</B></FONT> 
<a href="http://www.mysite.com/members/members.html">
<FONT SIZE="2" COLOR="1600A5" FACE=VERDANA><B>Message boards</B></FONT></a>
</CENTER>
</BODY>
</HTML>


If I move the forum, some folks will still be linked to:
http://www.mysite.com/fudforum/index.php
This index.php will load the forum. BUT since I have moved the index.php, I want to put a new index.php with the above code.

So, What would the code look like for the index.php to do the META refresh? How about the following? Would this work?

<?php
<!doctype HTML public "-//w3c//dtd HTML 4.0 transitional//en">
<HTML>
<HEAD>
<META HTTP-EQUIV=REFRESH CONTENT="8;URL=http://www.mysite.com/members.html">
</HEAD>
<BODY>
<P>&nbsp;</P><P>&nbsp;</P>
<CENTER>
<FONT SIZE="2" COLOR="1600A5" FACE=VERDANA><B>
You will automatically be redirected to the Message boards.
<BR><BR>
Or click the link if you can't wait!!!
</B></FONT> 
<a href="http://www.mysite.com/members/members.html">
<FONT SIZE="2" COLOR="1600A5" FACE=VERDANA><B>Message boards</B></FONT></a>
</CENTER>
</BODY>
</HTML>
?>


The META refresh option as used above will wait 8 seconds after loading before loading the URL that follows.

I appreciate your help and response...I learned enough PERL to be dangerous....guess I'm just going to have to do the same with PHP....<g>


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Re: how do I create a redirect in a php file [message #6649 is a reply to message #6648] Sun, 20 October 2002 23:38 Go to previous messageGo to next message
valiant is currently offline  valiant   Switzerland
Messages: 80
Registered: September 2002
Location: Zurich
Karma: 0
Member
I appreciate your help and response...I learned enough PERL to be dangerous....guess I'm just going to have to do the same with PHP....<g>

great Smile

k, what you want is a site that must be named index.php and must redirect to a certain other index.php, i guess i got that now Smile

your proposal in <?php ?> wouldn't work.
the problem is that everything between php brackets is parsed and should be php code. but you place there normal html.

the way it works is a normal html redirect page (your former solution (the above one). just name the file containing the ordonary HTML index.php and it should work.

php parses only code within <?php ?> brackets. so you can produce normal html pages without any php and name the file index.php and it should work.

why don't you just try the examples yourself? Wink

good night - andy
Re: how do I create a redirect in a php file [message #6651 is a reply to message #6649] Sun, 20 October 2002 23:54 Go to previous messageGo to next message
esm2002 is currently offline  esm2002   United States
Messages: 339
Registered: May 2002
Location: Atlanta Georgia
Karma: 0
Senior Member
aha! I see...php is actually programming inside of html....if in fact that is a correct interpretation, then, strangely enough, I am familiar with that concept.

Actually, I did think of trying it out...but as you say, it would not have worked.

Now I just need to get the good folks here to help me move the board...


Thanks for your help!!!


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Re: how do I create a redirect in a php file [message #7275 is a reply to message #6629] Thu, 14 November 2002 21:38 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
<?php
        header('Location: http://www.mydomain.com/mynewindex.php');
?>


that is an immediate redirect.
Re: how do I create a redirect in a php file [message #19130 is a reply to message #6629] Sat, 26 June 2004 22:56 Go to previous messageGo to next message
healthnews is currently offline  healthnews   United States
Messages: 3
Registered: June 2004
Location: interenet
Karma: 0
Junior Member
Hello

also, u can do it from your cpanel (permanent or temp redirects)
Re: how do I create a redirect in a php file [message #21886 is a reply to message #7275] Sat, 25 December 2004 06:23 Go to previous message
phpistasty is currently offline  phpistasty   United States
Messages: 2
Registered: December 2004
Location: e-ville In
Karma: 0
Junior Member
Quote:

<?php
header('Location: http://www.mydomain.com/mynewindex.php');
?>


keep in mind that you can do this with php - it is server side, but put it at the top , to modify the header it has to come up before anything is sent back to the browser - probably your best bet since <meta > isn't fullproof - and most things i've seen which talk about meta refreshes say not to use it as a permanent redirect - .htaccess files work to , because you can still have the browser show the old path - but it actually references a different document , look for mod_rewrite on google


smldb:200k+
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Parse error in line 206
Next Topic: Pop window loads link # and store it in variable
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 11:01:04 GMT 2024

Total time taken to generate the page: 0.02060 seconds