Skip to content

Instantly share code, notes, and snippets.

@meSingh
Forked from gbaptista/fix_domain.php
Created February 11, 2013 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save meSingh/4755363 to your computer and use it in GitHub Desktop.
Save meSingh/4755363 to your computer and use it in GitHub Desktop.
<?php
$mysql_host = 'localhost';
$mysql_user = '';
$mysql_pass = '';
$mysql_base = 'wordpress_database';
$old_domain = 'http://blog.gbaptista.com';
$new_domain = 'http://local.blog.gbaptista.com';
if($conn = mysql_connect($mysql_host, $mysql_user, $mysql_pass)) {
mysql_select_db($mysql_base, $conn);
} else {
echo mysql_error(); mysql_close($conn); exit;
}
mysql_query("UPDATE wp_posts SET guid=REPLACE(guid, '$old_domain', '$new_domain') WHERE guid LIKE '%$old_domain%'");
mysql_query("UPDATE wp_options SET option_value=REPLACE(option_value, '$old_domain', '$new_domain') WHERE option_value LIKE '%$old_domain%'");
echo "\nDone! [$old_domain to $new_domain] =)\n\n";
mysql_close($conn);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment