301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. It’s not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it’s the safest option. The code “301″ is interpreted as “moved permanently”. If been looking around for the ways on how to do this. So this is what i’ve found:
ASP.NET
1 2 3 4 5 6 | <script runat="server"> private void Page_Load(object sender, System.EventArgs e){ Response.Status = "301 Moved Permanently"; Response.AddHeader("Location","http://www.new-url.com"); } </script> |
Classic ASP (ASP3.0)
1 2 3 4 5 6 | <%@ Language=VBScript%> <% Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www.new-url.com/" Response.End %> |
PHP Redirect
1 2 3 4 5 | <?php Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.new-url.com" ); exit(); ?> |
Redirect Old domain to New domain (htaccess redirect)
The code belew, which you place into a file called .htaccess in the root folder of your old domain, 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)
1 2 3 | Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.new-domain-name.com/$1 [R=301,L] |
NOTE: REPLACE www.new-domain-name.com in the above code with your actual domain name.
NOTE: This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
Redirect to www (htaccess redirect)
Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
As with the last example, 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)
1 2 3 4 | Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] |
NOTE: Replace domain.com with your domain name
NOTE: Both of these last examples ONLY works on Linux servers having the Apache Mod-Rewrite moduled enabled.
And there you have it. You can Test your redirection with Search Engine Friendly Redirect Checker






Recent Comments