Moving blog/website safely
16 Oct 2009 , Posted in Technology, Web
Abstract
This post is written for helping the webmasters to keep the links alive while restructuring their websites.
Author: Nisha S.Tags: Address, Blog, URL change, Website
Are you newly starting with a website or blog. It is a good idea to define the folder structure or categories in advance. Because as soon as it goes to public search engines slowly starts indexing your website. So after some long time, if you change the structure of the web it could be a worse decision with the following reason.
- You will loose many incoming links which already given from good other site, which will may you to loose your page rank.
- If some one bookmarked your website URL already they will end up with page not found page while they are visiting back to through bookmarks.
- Search engines may keep the old index without updated unless you are providing page redirect and index the new moved content as duplicate content. So you will not get the same value for the content which you gets when you publish initially.
Even though there is many reasons not to restructure your website or blog, in some circumstance it is becoming a must to do it. So here I am going to explain that how you can move the contents in your website without damaging any of your website values.
So I will start with an example so that you can understand the thing simply, and the examples are in PHP you can apply the same concept in the language which you have in your website. Here let say we have installed a blog in http://www.betterhelpworld.com/reading and planning to move to the root http://www.betterhelpworld.com. So if a old url exist as http://www.betterhelpworld.com/reading/index.php/jokes/the-corporate-language/ the same will be as http://www.betterhelpworld.com/index.php/jokes/the-corporate-language/ after moving moving the blog to the root. So who ever visits to the folder http://www.betterhelpworld.com/reading/xxxxxx should be redirected to http://www.betterhelpworld.com/xxxxxx. We can do a simple redirect for that, but in that case search engines will not re-index the url. So we need to say search engines that is a permanent redirect by passing the code 301. So before sending the new url header information we will pass the 301 message.
header("HTTP/1.1 301 Moved Permanently");
After passing the 301 message we will pass the new url as below.
header("Location: " . $new_url);
But before that we need to find the new url and should assign to $new_url. That code will be like the following.
$url = $_SERVER["REQUEST_URI"]; $new_url = str_replace("/reading/", "/",$url);
That is all. This will resolve all the issues comes when we restructuring the website. The challenging part may be formulating the regular string when you do a complete restructuring of a big website. Other than that it will be very simple script in any language. Have a safe restructuring.
Please see the complete code below.
<?php $url = $_SERVER["REQUEST_URI"]; $url = str_replace("/reading/", "/",$url); $url = str_replace("reading.betterhelpworld.com", "betterhelpworld.com",$url); $url = "http://www.betterhelpworld.com" . $url; header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $url); ?>
Please comment your feedback to improve this post further.
Updated : All the sample coding should be in a file index.php in the folder reading as per the example.



January 3rd, 2010 at 1:19 am
WowI hadn’t considered the apparently simple ways a search engine like Google thinks. The issue is that Search Engines “indexes” your page abundant times, it takes a ton of due work on your part to get a page to become intriguing to the spiders. I guess this lends to my understanding of search engines.