Hi you use in 301 redirection for details as under:
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
<%@ Language=VBScript %>
Response.Status="301 Moved Permanently"
ASP .NET Redirect
private void Page_Load(object sender, System.EventArgs e)
Response.Status = "301 Moved Permanently";
JSP (Java) Redirect
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
CGI PERL Redirect
$q = new CGI;
Ruby on Rails Redirect
headers["Status"] = "301 Moved Permanently"
Redirect Old domain to New domain (htaccess redirect)
Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Please REPLACE www.newdomain.com
in the above code with your actual domain name.
In addition to the redirect I would suggest that you contact every backlinking site to modify their backlink to point to your new website.