Palagpat Coding

Fun with JavaScript, game theory, and the occasional outbreak of seriousness

Sunday, April 25, 2010

How to move to Blogspot and keep your blog on your own domain

Recently faced with the problem of how to have my blogs remain in their pre-existing locations while complying with Blogger's mandatory move away from FTP publishing, I think I've found a pretty easy solution: if you're on a LAMP server (which I suspect most of you are; it's nearly ubiquitous), it's as easy as removing all other index.* files and creating a new index.php file in the appropriate folder, and dropping in these 5 lines of PHP code, changing the URL in the first line as appropriate:

$session = curl_init("http://your.web.address");
curl_setopt($session, CURLOPT_HEADER, 0);
$content = curl_exec($session);
echo $content;

cURL is the secret sauce in there, and I could go into a lot more depth, but if you don't need to worry about authentication or anything more complex than a simple page-fetch, there's no need. I allow the post-comments and labels pages to link directly to Blogspot, and I use Feedburner to host my RSS feeds, so this simple solution gets me 95% of the way there. The rest is just resource-management and wise template design.

I love it when something that looks like it'll be difficult turns out to be so easy! But please, if I'm doing anything that opens me up to possible security problems (I don't think I am, but...), please let me know in the comments.

Labels: , , ,


Post a Comment

Subscribe to Post Comments [Atom]

<< Home