Monday, January 12, 2009

redirect to blogspot

I found that a lot of domain registrars with dns server don't allow to create CNAME to main domain (your-domain.com). You need to create subdomain (www.your-domain.com or blog.your-domain.com) for CNAME to ghs.google.com. .

It's good if you have homepage (your-domain.com) and blog(blog.your-domain.com).

But blogspot for me is homepage and blog )). So i redirect from your-domain.com to www.your-domain.com( CNAMEd ghs.google.com).

I use apache mod_rewrite and php.
.htaccess

RewriteEngine on
RewriteRule ^(.*)$ index.php?$1 [QSA,L]


index.php

<?php
error_reporting(0);
$uri = $_SERVER['QUERY_STRING'];
$uri = str_replace("index.php&", "", $uri );
$uri = str_replace("index.php", "", $uri );
header("Location: http://www.your-domain.com/{$uri}");
?>
Powered by Blogger.