SEO Redirect or 301 Redirect

February 19 | Posted by Ankit | SEO Tags: , ,

SEO redirect or 301 redirect is one of the best Search Engine Friendly method to redirect a webpage. It is easy to implement and it will preserve your rankings for that page. 301 redirect means “moved permanently”.

You can also use this tool Redirect Checker to check if your page is 301 redirect or not.

Here are some of the common of the common examples of 301 redirect you can use with your website:

Search Engine considers ankitrawat.com/ and www.ankitrawat.com/ both Different websites. So you have to redirect one of them to other so as to have a same PR.

This is not a new issue its already discussed lots of time like in 2005 Dan wrote a post in his blog example.com vs www.example.com.

Well here I’m Telling you the code you have to put into your .htacess file into the root folder of your control panel.

The code to redirect ankitrawat.com/ to www.ankitrawat.com/ would be as follows:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.ankitrawat.com/ [NC]
RewriteRule ^(.*)$ http://www.ankitrawat.com//$1 [L,R=301]

Code to redirect www.ankitrawat.com/ to ankitrawat.com/ will be:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^ankitrawat.com/ [NC]
RewriteRule ^(.*)$ http://ankitrawat.com//$1 [L,R=301]

Now last night I was browsing DP and there a guy asked he want to change his website url. (Domainname.com to Domainname.org) or we can say he wanted to move his domain without loosing search engine ranks… so here we go with the coding part…

301 code to Move your domain to www.ankitrawat.com/:

RewriteEngine On
RewriteRule ^/(.*)$ http://www.ankitrawat.com//$1 [R=301,L]

You can also redirect sub-domains. Just add the below code into the .htaccess inside the root of your olddomain.com.

Code to redirect sub-domains of Your olddomain.com to ankitrawat.com/:

RewriteEngine On
RewriteCond %{HTTP_HOST} (.*)olddomain.com
RewriteRule ^(.*) http://%1ankitrawat.com//$1 [R=301,L]

If you have moved some old page to a new page and want all visitors and search bots to redirect to your new page simply put any of the code into your old page :

301 PHP redirect Code to redirect old page to www.ankitrawat.com/:

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

301 JSP (Java Script) redirect code to redirect old page to www.ankitrawat.com/:

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

It is strongly recommended that you should contact all the website owners earlier linking your website or pages to link your new website or page. Right now Google is passing all the search ranking and Pagerank redirect under 301 code.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: , ,

5 Responses to “SEO Redirect or 301 Redirect”

  1. angilina says:

    Thanks for this informative article

  2. Joe says:

    Interesting. Any idea how one would accomplish this on a windows server?

  3. Fezzy says:

    You can also use redirect plugins for WordPress blogs , i use it on my own blog. Click my name to check it out.

    Search Google for “Redirect Plugin WordPress” and a download of the plugin comes up first.

  4. g1smd says:

    There’s an error in the third example.

    The leading slash is not available to the RewriteRule, nothing will ever match.

  5. Ankit says:

    Can u tell me about which example u talking abt ?

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>