Giter Site home page Giter Site logo

wordpress-domain-changer's Introduction

WordPress Domain Changer Build Status

A stand-alone tool that helps ease the migration of WordPress sites from one domain/URL to another.

Instructions

  1. Backup your WordPress site's database.
  2. Seriously, Back Up Your Database!
  3. Situation One: The WordPress files and database have not moved -- only the domain/URL has changed.
    • Skip to step 5.
  4. Situation Two: You intend to move an existing WordPress site to a new server.
    1. Export the current WordPress database to a SQL dump file.
    2. Create a MySQL database on the new server and import the SQL dump file.
    3. Open up the WordPress wp-config.php file and set the DB_HOST, DB_USER, DB_PASSWORD, and DB_NAME constants to the correct values for the new server.
    4. Upload the WordPress files to the appropriate directory on the new server.
  5. Open up the wpdc/config.php file and replace the default password with a VERY secure password of your choice.
  6. Upload the wpdc/ directory itself to the root directory of your WordPress site.
    • Note: The root directory is where the wp-config.php file is located.
  7. Open a web browser and navigate to: http://whatever-your-new-domain-is.com/wpdc
  8. Login with the password you entered in Step 6.
  9. Follow the on-screen instructions & steps.
  10. Remove the wpdc/ directory from the server when you're finished.

Website

Blog Post & Overview

License

WordPress Domain Changer is released under the New BSD license.

Author

Daniel Doezema

Contributors

wordpress-domain-changer's People

Contributors

kevindeleon avatar mike-rsi avatar veloper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wordpress-domain-changer's Issues

Support for MU websites

MU websites have extra tables that require attention.
The script should be updated to support that.

Semicolon lost after fixing serialized data

What I saw was the script change something like this, but lose the semicolon after .com"

{s:4:"home";s:37:"http://www.twdcompassionvetclinic.com";s:4:"link";

Below I made a little example using functions from script

<?php

function my_preg_quote($string, $delimiter = null) {
    $string = preg_quote($string, $delimiter);
    if(phpversion() < 5.3) $string = str_replace('-', '\-', $string);
    return $string;
}

function regExpSerializeEncode($string) {
    if(preg_match_all('!s:[0-9]+:"(.+?)";!', $string, $matches)) {
        foreach($matches[1] as $match) {
            $string = str_replace($match, str_replace('"', '[DOUBLE_QUOTE]', $match), $string);
        }
    }
    return $string;
}

function regExpSerializeDecode($string) {
    return str_replace('[DOUBLE_QUOTE]', '"', $string);
}

function serializedStrReplace($find, $replace, $haystack) {
    $length_diff = strlen($replace) - strlen($find);
    $find_escaped = my_preg_quote($find, '!');
    if(preg_match_all('!s:([0-9]+):"([^"]*?'.$find_escaped.'{1}.*?)";!', regExpSerializeEncode($haystack), $matches)) {
        $matches = array_map('regExpSerializeDecode', $matches);
        $match_count = count($matches[0]);
        for($i=0;$i<$match_count;$i++) {
            $new_string = str_replace($find, $replace, $matches[2][$i], $replace_count);
            $new_length = ((int) $matches[1][$i]) + ($length_diff * $replace_count);
            $haystack = str_replace($matches[0][$i], 's:'.$new_length.':"'.$new_string.'"', $haystack);
        }
    }
    return $haystack;
}

$testStr = 'a:4:{s:25:"dashboard_recent_comments";a:1:{s:5:"items";i:5;}s:24:"dashboard_incoming_links";a:5:{s:4:"home";s:37:"http://www.twdcompassionvetclinic.com";s:4:"link";s:113:"http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:http://www.twdcompassionvetclinic.com/";s:3:"url";s:146:"http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:http://www.twdcompassionvetclinic.com/";s:5:"items";i:10;s:9:"show_date";b:0;}s:17:"dashboard_primary";a:7:{s:4:"link";s:26:"http://wordpress.org/news/";s:3:"url";s:31:"http://wordpress.org/news/feed/";s:5:"title";s:14:"WordPress Blog";s:5:"items";i:2;s:12:"show_summary";i:1;s:11:"show_author";i:0;s:9:"show_date";i:1;}s:19:"dashboard_secondary";a:7:{s:4:"link";s:28:"http://planet.wordpress.org/";s:3:"url";s:33:"http://planet.wordpress.org/feed/";s:5:"title";s:20:"Other WordPress News";s:5:"items";i:5;s:12:"show_summary";i:0;s:11:"show_author";i:0;s:9:"show_date";i:0;}}';
echo $testStr;
echo '<br><br>';
echo serializedStrReplace ('twdcompassionvetclinic', 'twdshorter', $testStr);
echo '<br><br>';
echo 'BAD: s:25:"http://www.twdshorter.com"s:4';
?>

I can't get this new version to work

When I create the /wpdc subdirectory from the wordpress root, and copy all the files, then when the browser points to www.myaddress.com/wpdc I get an error message

Notice: Unable to find "wp-config.php" ... Make sure the class.DDWordPressDomainChanger.php file is in the root WordPress directory.

So I am finding the class, but it can't find the wp-config.php because that IS in the wordpress root and the class domain changer.php is in /wpdc/classes.

Your old PHP program changes the domain fine, but this one doesn't work as is.

NGINX set up

Hi,

Firstly, thanks for making this little app. It's super useful and we use it so much!

I'm trying to create it's own virtual host on my VM machine for development. I'm using NGINX and I can't get the config right, so I was wondering if you could help me?

My NGINX config is:

server {
        listen 80;

        root /vagrant/www/wpdc/wpdc;
        index index.php index.html index.htm;

        server_name wpdc.dev;

        location / {
                # try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}

The error from access.log I'm getting is:

192.168.10.1 - - [18/Oct/2016:16:05:55 +0000] "GET /index.php/login HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"

And on Chrome it is saying:

The wpdc.dev page isn’t working

wpdc.dev redirected you too many times.

ERR_TOO_MANY_REDIRECTS

Any idea what I am going wrong?

PHP Seralized Values

A strait find/replace will not work on serialized values as the length of the data is stored in the serialized string.

This means that if there is a plugin storing data in a serialized array, and within that serialized array the Old Domain value exists, then it will get replaced by the New Domain, but the length value will not get updated.

This causes an error to be triggered when unserialize() is called on the string as it's now invalid/corrupt after the find/replace.

Does not take into consideration postmeta

I had a rather large site that uses custom post types and custom fields. Anything uploaded through the media uploader into these custom fields gets stored in post meta, so there were quite a bit of urls(over 100) that needed changing in there. I added this to your code and it worked great. Something you may consider. Great script by the way.

//Update postmeta
$result = $mysqli->query('UPDATE '.$data['prefix'].'postmeta SET meta_value =
REPLACE(meta_value,"'.$data['old_domain'].'","'.$data['new_domain'].'");');
if(!$result) {
throw new Exception($mysqli->error);
} else {
$DDWPDC->actions[] = 'Old domain ('.$data['old_domain'].') replaced with new domain ('.$data['new_domain'].') in '.$data['prefix'].'postmeta.meta_value';
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.