phph redirect

Hello,
I don’t know php language. I need a redirect script in my root dir to put on index.php that redirects old.domain.com/whatever to new.domain.com/whatever

I am not sure to be clair,
I hope to find help.

Giovanni

1.<?php
header( ‘Location: http://www.yoursite.com/new_page.html’ ) ;
?>

Change the code on the redirect page to be simply this. You need to replace the URL above with the URL you wish to direct to.

2.Be sure that you do not have any text sent to the browser before this, or it will not work. Your safest bet is to simply remove all content from the page but the redirect code.

<?php //this will NOT work, the browser received the HTML tag before the script header( 'Location: http://www.yoursite.com/new_page.html' ) ; ?>

Tips:

1.Remove all code but this
2.Mention on the new page that user’s should update their links and bookmarks
3.You can use this code to create a drop down menu that redirects users pages

Thanks to : http://php.about.com/od/learnphp/ht/phpredirection.htm

The way I redirect is create a specific function that will redirect to a page REGARDLESS of if headers are sent before. Below is the function I created that I use on my websites:

[php]
function ForceRedirect($page, $time)
{
# Close all active HTML
echo ‘’;

   # Redirect
   echo '<html><head><meta http-equiv="refresh" content="'.$time.';url='.$page.'"></head></html>';

}

[/php]

This function allows you to redirect in the middle of displaying a page. $page is the location where you will redirect to and $time is the time in seconds that it will take to redirect. Hope this helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service