URL forwarding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sheepz
Forum Commoner
Posts: 58
Joined: Wed Jul 06, 2005 11:35 pm

URL forwarding

Post by sheepz »

i have a website www.website.com that i'm building but it's not done. so other pages are done but still working on the front end. so i want to be able to route all visitors to www.website.com/testing/index.php i tried using the header() but i'm guessing because i'm using meta tags it's sending out packets before the header and causing it to error out.

i need the http://www.website.com/index.php to stay there because i need the meta tags to populate thru the name servers and i'm currently working on it. is there a way i can have visitors come in and get re-routed automatically without clicking on any link? perferablely without any wait time. thanks :mrgreen:
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Put your header calls before your meta tags

Code: Select all

<?php
header('location ...');
?>
<html>
<head>
<meta ...
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

scottayy wrote:Put your header calls before your meta tags

Code: Select all

<?php
header('location ...');
?>
<html>
<head>
<meta ...
fyi, always include an exit() call after any header to prevent other code from potentially being executed.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Jcart wrote:fyi, always include an exit() call after any header to prevent other code from potentially being executed.
Totally true, I use die() though (doesn't really matter :P).
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

die() is exit() - its an alias ;)

You can also use output buffering if placing headers above meta tags is too much trouble - http://ie.php.net/manual/en/ref.outcontrol.php
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Maugrim_The_Reaper wrote:die() is exit() - its an alias ;)
I know that :P
sheepz
Forum Commoner
Posts: 58
Joined: Wed Jul 06, 2005 11:35 pm

Post by sheepz »

thx if i use the or die command i thought it wont read any code after that. it will still read the meta tags and other codes etc? i will go ahead and test that out. if i could ask one more question 8O

for future purposes, how would i code this, when a user enters a link or download, etc., and i want to re-direct them but i would want a wait time. like this site for instance. after posting, it will perform this: wait 5 seconds and it will re-direct you if not click here. hows that done? :D
Post Reply