Un nou nume de domeniu

Pentru a nu mai amesteca page rankurile/serp-urile de la 12s si bakblog, am cumparat un domeniu nou, care se vede acum, snowunderstarlight.com . Cu ocazia asta a si trebuit sa scriu un script de php pentru a converti url-urile din post-urile wordpress, care erau hardcodate in html 🙁

Iata si codul:

< ?
error_reporting(E_ALL);
ini_set("display_errors", "on");

// ** MySQL settings ** //
define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'db user'); // Your MySQL username
define('DB_PASSWORD', 'db pass'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME);
$queryLoad = "
SELECT
*
FROM
wp_posts
"
;

$rQueryLoad = mysql_query($queryLoad);
$aPosts = array();
$iCountQuery = mysql_num_rows($rQueryLoad);
for($i = 0; $i < $iCountQuery; $i ++) {
$aPosts[] = mysql_fetch_object($rQueryLoad);
}
foreach($aPosts as $oPost) {

echo 'Updating '.$oPost->post_title.'
'
;
$sContent = $oPost->post_content;
$sNewContent = str_replace("http://bakblog.12silence.com/", "http://www.snowunderstarlight.com/", $sContent);
$sUpdateQuery = "
UPDATE
wp_posts
SET
post_content = '"
.addslashes($sNewContent)."'
WHERE
ID = "
.$oPost->ID."
"
;
mysql_query($sUpdateQuery);
}

?>

In plus, ca sa mi se transmita la un moment dat PR-ul din vechea pagina am pus un mic redirect acolo 🙂

< ?
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.snowunderstarlight.com".$_SERVER['REQUEST_URI']);
?>

Asta in conjunctie cu .htaccess-ul / regulile de rewrite din wordpress.
Cam atat, total offtopic.

1 comment on “Un nou nume de domeniu

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>