Man, that is one LONG title. Need to properly redirect pages on your website? Note the term “properly”. Obviously this is a subjective term, but when it comes to our Search Engine friends, we need to make sure that we are properly instructing those SE robots how to navigate and index our redirects.
So we introduce you to the 301 Redirect. 301 redirecting is the most efficient, but more importantly, the most Search Engine Friendly method of redirecting web pages. It’s actually quite simple to integrate, given you are comfortable in your native and preferred language environment. For those that are craving to know, the “301″ code is interpreted by SE’s as “moved permanently”.
Quick inLinks: IIS 301 Redirect, ColdFusion 301 Redirect, PHP 301 Redirect, ASP 301 Redirect, ASP.NET 301 Redirect, JSP 301 Redirect, CGI PERL 301 Redirect, Ruby on Rails 301 Redirect, HTACCESS 301 Redirect
IIS 301 Redirect
- In internet services manager, right click on the file or folder you wish to redirect
- Select the radio button titled “a redirection to a URL”.
- Enter the redirection page
- Check “The exact url entered above” and the “A permanent redirection for this resource”
- Click on ‘Apply’
ColdFusion 301 Redirect
<.cfheader statuscode="301" statustext="Moved permanently"> <.cfheader name="Location" value="http://www.new-url.com">
PHP Redirect
<?
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://www.new-url.com");
?>
ASP 301 Redirect
<%@ Language=VBScript %> <% Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www.new-url.com/" %>
ASP .NET 301 Redirect
<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>
JSP (Java) 301 Redirect
<%
response.setStatus(301);
response.setHeader("Location", "http://www.new-url.com/" );
response.setHeader("Connection", "close" );
%>
CGI PERL 301 Redirect
$q = new CGI;
print $q->redirect("http://www.new-url.com/");
Ruby on Rails Redirect
def old_action headers["Status"] = "301 Moved Permanently" redirect_to "http://www.new-url.com/" end
HTACCESS 301 Redirect Old domain to New domain
Note* This .HTACCESS method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite module enabled.
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 home page file is placed).
Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Do not forget to REPLACE www.newdomain.com in the above code with your actual domain name.
HTACCESS Redirect to www
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. 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).
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Do not forget to REPLACE domain.com in the above code with your actual domain name.
HTACCESS Redirect Single page to New page
Create a .HTACCESS file with the below code, it will ensure that all requests coming in to your web page will get redirected to it’s new page. 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).
Redirect 301 /old-file.html http://www.yourdomain.com/new-file.html
Do not forget to REPLACE paths and yourdomain.com in the above code with your actual domain name.
HTACCESS Redirect Single directory to New directory
Create a .HTACCESS file with the below code, it will ensure that all requests coming in to your web page will get redirected to it’s new page. 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).
Redirect 301 /old-folder http://www.yourdomain.com/new-folder
Do not forget to REPLACE paths and yourdomain.com in the above code with your actual domain name.
