AZForums: Redirect Using PHP - AZForums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Redirect Using PHP

#1 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 02 March 2006 - 06:48 PM

Use this code if you want to redirect visitors to another URL;

<?php
//Redirect Browser
header("Location: http://www.YourSite.com/");
?>


Add it at the very top of your document, before the <html> tag.
remember to save the document as .php or it just wont work.

This post has been edited by Oosband: 05 March 2006 - 03:06 PM

0

#2 User is offline   Blade Icon

  • Survivor
  • PipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Platinum
Posts:
3,154
Joined:
29-August 05
Location:
--

Posted 03 March 2006 - 07:51 PM

Very useful, but stop advertising dude.

I have used php a few times, and I have wanted to find this, thanks.
0

#3 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 05 March 2006 - 03:05 PM

If your server doesn't support PHP...just use this instead:

<meta http-equiv="Refresh"
content="5;url=http://www.YourSite.com">


Place that in the <head> section of your site.
The 5 is the amount of seconds it takes to redirect, the YourSite.com is the url it redirects to...change that ;)
0

#4 User is offline   devcline Icon

  • AZ Beginner
  • PipPip
  • View blog
Group:
Members
Posts:
21
Joined:
11-November 08

Posted 24 February 2009 - 01:38 AM

function urlRedirect($url)
{


if ( !headers_sent() ) {
header('Location: '.$url);
exit;
}

echo '<script type="text/javascript">window.location.href="'.$url.'";</script>' .
'<noscript><meta http-equiv="refresh" content="0;url='.$url.'" /></noscript>';

exit;

}
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users