For various reasons webmasters may need to move a domain name or redirect a webpage and at the same time keep thier search engine ranking; this can be done by setting up a 301 Moved Permanently redirect in either php or htaccess.
Php
Insert the following code at the top of the php file that you wish to redirect:<?php
$redirect = "http://www.example.com";
header("HTTP/1.1 301 Moved Permanently");
header("location:$redirect"); exit();
?>
HtaccessRewriteEngine on
Options +FollowSymlinks
RewriteRule filename.html$ /redirect_url.html [R=301,L]
A 301 redirect is vital if you are moving page as it informs robots/crawlers that a page has moved permanently and helps retain its original value.
in Php, Htaccess