What is 301 Redirection?
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".
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
-or-
Options
+FollowSymLinksRewriteEngine onRewriteCond
%{HTTP_HOST} ^example\.comRewriteRule ^(.*)$
http://www.example.com/$1 [R=permanent,L] -or-
Options
+FollowSymLinksRewriteEngine onRewriteRule (.*)
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_actionheaders["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:
Here content="5" means the time (e.g. 5) in second the browser should wait before redirecting to new location.
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.
No comments:
Post a Comment