View Full Version : V.Simple PHP Redirection Tut.
The Voice
06-08-2006, 08:13 PM
Ok, if you dont hav e cPanel and can't take advantage of the really simple Redirection thing, then you'll need the following php code. For example if you wanted your site (http://www.example.com) to redirect to (http://www.example.com/forums) then you'll need to create a new document in the public_html directory called 'index.php' and add the following code.
<?PHP
header("Location: http://www.example.com/forums");
?>
If you would like to add a delay in the redirect then add the following code.
<?php
header("Refresh: 5; URL=http://www.example.com/forums");
?>
Replace 5 with the amount of second you wish for the delay.
That's it.
Mentor
06-08-2006, 08:15 PM
urmm im not a 100% but your second code looks like a meta refresh in php header tags "/ wouldnt that just cause an error message "/
The Voice
06-08-2006, 08:19 PM
I wouldn't post it without testing it. I've used it quite frequently in my Dad's sites as he bought one without cPanel once.
Evasion
07-08-2006, 09:15 AM
Looks good.
ClubTime
07-08-2006, 06:39 PM
Yeah thanks, but most of us have cPanel and can redirect.
reindeer.
07-08-2006, 06:41 PM
Exactly. MOST of us. ;) There might be a few people who dont still :)
The Voice
07-08-2006, 06:54 PM
I know, I have cPanel. Most people do have cPanel. Some dont. Also, on cPanel you can put a delay. You might have changed your site name and when you go onto the old site it says.
Just a quick not to say, ou name has changed to 'soandso' at the domain 'http://www.soandso.com'. Soon, this domain will be out of use, so please get into the habbit of using the new domain.
And have a delay of 15 seconds whilst the user reads the message then it automatically redirects them.
reindeer.
07-08-2006, 07:43 PM
Well put ;)
Sygon.
07-08-2006, 07:50 PM
Never knew the refresh: bit, thanks.
reindeer.
07-08-2006, 07:58 PM
Ill use that in future if needed - thanks.
Oracle:
07-08-2006, 08:20 PM
If your going to re-direct somethen then .htaccess for the win.
cunning
08-08-2006, 06:32 AM
Looks good but more understandable if you go to http://techtuts.com/?view=tutorials&act=tutorial&id=554
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.