Below are some of the ways on how to redirect a website. They are:
How to Redirect a website using 301 Redirect code
301 redirect is the most efficient and Search Engine Friendly method to redirect a website or webpage. You only need a simple code made a permanent redirect url on the fly. If you have to change file names or move pages around, it’s the safest option. The code “301” is interpreted as “moved permanently”.
Below are a Couple of methods to implement URL Redirection via code and htaccess redirect
How to Redirect a website using ColdFusion Redirect
Example
<.cfheader name=”Location” value=”http://www.new-url.com”>
How to Redirect a website using PHP Redirect
Example
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.new-url.com” );
?>
How to Redirect a website using ASP Redirect
Example
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.new-url.com/”
%>
How to Redirect a website using ASP .NET Redirect
Example
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,”http://www.new-url.com”);
}
</script>
How to Redirect a website using JSP (Java) Redirect
Example
response.setStatus(301);
response.setHeader( “Location”, “http://www.new-url.com/” );
response.setHeader( “Connection”, “close” );
%>
How to Redirect a website using CGI PERL Redirect
Example
print $q->redirect(“http://www.new-url.com/”);
How to Redirect a website using Ruby on Rails Redirect
Example
headers[“Status”] = “301 Moved Permanently”
redirect_to “http://www.new-url.com/”
end
How to Redirect Old domain to New domain using 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)
Example
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Please REPLACE www.newdomain.com in the above code with your real 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.
Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
How to Redirect a website URL from www to non www using htaccess redirect
Create a .htaccess file with the below code, it will ensure that all requests coming in to www.domain.com will get redirected to domain.com
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)
Example
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^www.domain.com [nc]
rewriterule ^(.*)$ http://domain.com/$1 [r=301,nc]
Please REPLACE domain.com and www.domain.com with your real domain name.
Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.