website redirection
Moderator: General Moderators
website redirection
i have this old website which does not exist anymore eg.www.something.fr/index.php.
when a user enters the old website i want it to be automatically redirected to the new one..say http://www.something.com.
i suppose the codin goes into the header part.;
but i dont have any idea as to how it shud be done.
if anyone here can help me out..it wud be nice..
thank u
when a user enters the old website i want it to be automatically redirected to the new one..say http://www.something.com.
i suppose the codin goes into the header part.;
but i dont have any idea as to how it shud be done.
if anyone here can help me out..it wud be nice..
thank u
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
header("location: http://www.newsite.com");
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Don't forget to use exit():So that anything else on the page does not get processed when it doesn't need to, thus saving resources 
Code: Select all
<?php
header('Location: http://www.somesite.com');
exit(); //to prevent anything else being processed
?>How would that happen? Redirect directs immediately, unless you have any output prior to header() which invalidates the function and produces an error.Jenk wrote:Don't forget to use exit():So that anything else on the page does not get processed when it doesn't need to, thus saving resourcesCode: Select all
<?php header('Location: http://www.somesite.com'); exit(); //to prevent anything else being processed ?>
The PHP process will continue to process any script after the header is sent 
When you put, for example, http://mysite.com/index.php all that does is tell the Webserver to run the script. If the script outputs anything, then it will - one of those could be the redirect header. All the redirect header does is tell your browser to look else where.
The webserver will continue to process whatever else is within that file
When you put, for example, http://mysite.com/index.php all that does is tell the Webserver to run the script. If the script outputs anything, then it will - one of those could be the redirect header. All the redirect header does is tell your browser to look else where.
The webserver will continue to process whatever else is within that file
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
this is true.
if you run that script you will end up at devnetwork and not at google
Code: Select all
header("location: http://www.google.com");
header("location: http://www.devnetwork.net");