How to Put a 301 SEO Friendly Redirect

by Wali on 2010/07/01

Finally, I took the time off, and now we are on new address www.seotipss.com. Make sure you put double “ss” in Tipss. I thought I should make a post about how you can put a friendly 301 redirect on your blog.

If you have purchased a new domain and need to redirect old website or blog to a new website, you need to consider applying 301 permanent redirect. It will help you not to lose rankings in search engines. You can simply ask your web host o do the job for you. Luckily, my web host provides all the technical services for free. I am now using site5 hosting. However, if you need to set up anually, it will be very hectic for you, especially for newbies.

Single Page Redirect

You can consider this code when you are redirecting a single static page. All you need to do is put the code in your index.php file, and if there is any other code, put this one below by giving a space like pa paragraph.

?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.yournewdomainhere.com/page.html");
exit();
?>

Canonical Redirect

The canonical 301 redirect will help you add or remove www to all the pages. This code will redirect without www domain to www like seotipss.com to www.seotipss.com.  u can replace the code with your desired address.

<?php
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$_SERVER['HTTP_HOST']
.$_SERVER['REQUEST_URI']);
}
?>

.htaccess Single Page Redirect

You need to edit your .htaccess file and you can create a backup by downloading the file from File Zilla. You can find the .htaccess file in your root directory or if you are using wordpress you can find it in public_html folder.

Redirect 301 /old/oldpage.htm /new/http://www.yourdomainhere.com/newpage.htm

.htaccess Canonical Redirect

It is the same process you just need to put the code in .htaccess file. It will redirect users from without www to www domain.

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^yourdomainhere.com [nc]
rewriterule ^(.*)$ http://www.yourdomainhere.com/$1 [r=301,nc]

This will help you to set up 301 redirect on your blogs and website. I recommend that you use a webhost that provides all these services for free. It might be very confusing for newbies, as it was for me. Try to use the tools available in your webhost cpanel. Usually there are few options from where you can do this manually without using all the above codes.

Why we need 301 redirect? It will help you in search engines not to lose rankings. It is advisable before you make any change backup any data you have on your website. I lost my all the data of one blog before I asked my web host do the job for me. If you don’t have any idea, I would suggest you hire someone who is expert in handling the job. It is much better to pay someone rather losing all your important data on your website.

Leave a Comment

Previous post:

Next post: