How to 301 Redirect a Web Page - 301 Redirect Methods

blogging, general, seo 10922 Comments

301 redirect is the most efficient and search engine friendly (SEO) method for webpage redirection. One of the biggest advantage is that it also pass on the PageRank value and hence preserves the current search engine rankings for that particular page. It is the best and safest way in case of renaming or moving files to other location. The code "301" is normally interpreted as "moved permanently".

Use this free 301 URL Redirection Checker tool to check the redirection of a webpage.

Benefits of Redirection

A web page may be redirected for several reasons:

  • A web site might need to change its domain name.
  • An author might move his or her pages to a new domain.
  • Two web sites might merge.

With URL redirects, incoming links to an outdated URL can be sent to the correct location. These links might be from other sites that have not realized that there is a change or from bookmarks/favorites that users have saved in their browsers.

Different Methods to Implement URL Redirection

Following are some common ways to do 301 redirection in different languages. The example are taken from internet, so make sure if all the things work well before finally implementing them.

Redirect through .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
-or-
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

PHP Redirect
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.newdomain.com" );
?>

CGI PERL Redirect
$q = new CGI;
print $q->redirect("http://www.newdomain.com/");

Ruby on Rails Redirect
def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.newdomain.com/"
end

Java Redirect
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.newdomain.com/" );
response.setHeader( "Connection", "close" );
%>

ColdFusion Redirect
<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.newdomain.com">

ASP Redirect
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.newdomain.com/"
%>

ASP .NET Redirect
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.newdomain.com");
}
</script>

HTML Redirect (Meta Redirect)
To send someone to a new web page or site put this in the head section of your document:
<meta http-equiv="refresh" content="5"; url=http://newdomain.com/">
Here content="5" means the time (e.g. 5) in second the browser should wait before redirecting to new location.

To check redirection of a web page, use this tool : 301 URL Redirection Checker

elegant themes banner

Related Articles:

You may be interested in:

Mike Smith writes for WebToolHub.com. He loves to golf, cook and explore music in his free time.

Would you like to contribute to this site? Get started ยป
Rate this article:
(4.5 rating from 6 votes)

Comments