TestClear

Author Topic: Auto Redirect - PHP Tutorials  (Read 89993 times)

Offline admin

  • Administrator
  • *****
  • Posts: 68
  • Karma: +11/-0
  • Gender: Male
Auto Redirect - PHP Tutorials
« on: June 19, 2007, 07:49:40 PM »

Code: [Select]
<?php

$URL
="http://phpform.net/board";
header ("Location: $URL");

?>




« Last Edit: May 25, 2008, 04:55:14 PM by admin »

Offline Roby

  • Supporter
  • **
  • Posts: 4
  • Karma: +1/-0
Re: Auto Redirect - PHP Tutorials
« Reply #1 on: May 09, 2008, 03:07:15 PM »
Redirect in PHP without header( "Location:...:");

Code: [Select]
<?php
echo &#39;<META HTTP-EQUIV="Refresh" Content="0; URL=index.php">&#39;;    
exit;
?>
« Last Edit: May 25, 2008, 04:56:52 PM by admin »

Offline omentrance

  • Supporter
  • **
  • Posts: 1
  • Karma: +1/-0
Re: Auto Redirect - PHP Tutorials
« Reply #2 on: December 11, 2008, 10:28:27 PM »
I am new to this forum and have been reading all the posts. 

Even though this is an old post I think it should be noted that the meta refresh as a redirect is not recommended by the W3C even though it is almost universally supported now.

Also the header (location) redirect must be processed before any output to the browser.

Offline cilipe

  • VIP
  • ****
  • Posts: 14
  • Karma: +1/-0
Timed Redirect JavaScript
« Reply #3 on: October 10, 2009, 02:56:31 AM »
Code: [Select]
<?php
$redirect 
'http://phpform.net';
?>

<SCRIPT LANGUAGE="JavaScript">
redirTime = "550";
redirURL = "<?php echo $redirect ?>";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
</script>
<BODY onLoad="redirTimer()">
:) :)
« Last Edit: October 10, 2009, 04:05:37 PM by admin »

Offline alex

  • Global Moderator
  • *****
  • Posts: 77
  • Karma: +20/-0
Re: Auto Redirect - PHP Tutorials
« Reply #4 on: October 12, 2009, 12:41:09 AM »
Code: [Select]
<?php
$redirect 
'http://phpform.net';
echo 
"<center><font face=\"tahoma\">Click <a href=\"$redirect\">here</a> if your browser does not automatically redirect you</font></center>";
?>

<SCRIPT LANGUAGE="JavaScript">
redirTime = "2550";
redirURL = "<?php echo $redirect ?>";
function redirTimer() {
self.setTimeout("self.location.href = redirURL;",redirTime);}
</script>
<BODY onLoad="redirTimer()">
8) 8) 8) 8) 8) 8)

Offline michael32

  • Supporter
  • **
  • Posts: 1
  • Karma: +0/-0
Re: Auto Redirect - PHP Tutorials
« Reply #5 on: April 24, 2012, 08:29:11 PM »
Hi Guys! I want to know how to redirect 404 error to custom error page?  :)

Offline janos

  • Contributor
  • *****
  • Posts: 53
  • Karma: +4/-0
Re: Auto Redirect - PHP Tutorials
« Reply #6 on: April 24, 2012, 08:45:46 PM »
@michael32
Code: [Select]
<?php
header
('HTTP/1.0 404 Not Found');
header('Location: myerrorpage.php'); 
header('Connection: close');
die();
?>
:)

Offline janos

  • Contributor
  • *****
  • Posts: 53
  • Karma: +4/-0
Re: Auto Redirect - PHP Tutorials
« Reply #7 on: April 25, 2013, 12:10:16 PM »
with .htaccess

Code: [Select]
ErrorDocument 404 /myerrorpage.php