Hello everyone! 😀
As many of you might already know that I’ve been blogging for a long time now. First on Blogspot, then on wordpress.com and later to my self hosted wordpress 🙂 A few days back, I purchased a new domain — http://masnun.me is the new URL. I first hosted it on Google App Engine and kept my wordpress blog on masnun.com. I wrote a custom publication engine on GAE to make posts. I added a good number of features to it. But later I realized that GAE has no support for full text search. This pissed me off! I know I can hack to bypass that restriction (may be storing all keywords in a StringList type) but WordPress is amazing! Moreover, I realized that WP is already seo google, has a Google page rank 3 and most importantly earns me money from advertisements.
I finally decided to host masnun.me on my Umbrahosting account. Installed a fresh copy of WordPress, imported all previous data and then deleted the old blog. But what about the search engine factor? The previous blog had PR3 while the new one is not yet recognized in Google 🙁 Well, looks like I’m not out of luck properly. If Google finds certain URLs to forward to a new location with a “HTTP/1.1 301 Moved Permanently” response header, it’ll crawl the new pages and forward all attributes (PageRank included) to the new URL.
So, in my previous WP Directory, I have kept my WordPress .htaccess file intact and changed the contents of the index.php file to send a “HTTP/1.1 301 Moved Permanently” header and then forward to the new URL.
Here’s the code:
1 2 3 4 5 6 7 |
<?php $uri = $_SERVER['REQUEST_URI']; header("HTTP/1.1 301 Moved Permanently"); header("Location: http://masnun.me/{$uri}"); exit(); ?> |
Update: If your blog was on a sub directory – “blog”, delete that directory and put the following codes in the index.php file on the root of your previous URL:
1 2 3 4 5 6 7 8 9 |
<?php $uri = $_SERVER['REQUEST_URI']; if(substr($uri,0,5) == "/blog") { $uri = substr($uri,5); } #echo $uri; header("HTTP/1.1 301 Moved Permanently"); header("Location: http://masnun.me{$uri}"); exit(); ?> |
It’s working just fine! 🙂
One reply on “Forwarding Google Page Rank to New URL”
Useful information. Thanks for sharing.