Skip to main content
  1. All Posts/


Tools Open Source PHP WordPress

WP Change Domain

The wp-change-domain application is used to build a set of SQL commands and with that, update all urls of a wordpress installation (with all methods covered by php unit tests).


  • The source files is PSR-2 compatible.
  • Autoloading is PSR-4 compatible.

To install this web application you must run this commands on your terminal.

$ git clone
$ cd wp-change-domain/
$ composer install
$ bower install
$ npm install
$ grunt production
$ cp .env.example .env
$ mkdir -p storage/cache
$ mkdir -p storage/logs
$ chmod -Rf 777 storage/

Running a Web Server

After the steps that you followed to install this application, you must run a web server. So, type the following command on your terminal to create a web server.

$ php -S -t public public/index.php

Note that this command must be executed on root directory of this web application.


This web application was developed using AngularJS and with it you can change easily the domain of your wordpress installation.
Well, you can see below the HTTP routes where this application will handle your requests.
GET / will load the web application form.
POST /api/change-domain will receive a content type as application/json with the following content:

    "tablePrefix": "wp_",
    "numberOfBlogs": 1,
    "domainTo": "http://www.your.old.domain",
    "domainFrom": ""

This request will create a response where the content type will be application/json with the following content:

        "UPDATE wp_options SET option_value = REPLACE(option_value, u0027http://www.your.old.domainu0027, u0027 WHERE option_name = u0027homeu0027 OR option_name = u0027siteurlu0027 OR option_name = u0027ck_wp_panel_customu0027;",
        "UPDATE wp_posts SET guid = REPLACE(guid, u0027http://www.your.old.domainu0027, u0027;",
        "UPDATE wp_posts SET post_content = REPLACE(post_content, u0027http://www.your.old.domainu0027, u0027;",
        "UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, u0027http://www.your.old.domainu0027, u0027;",
        "UPDATE wp_site SET domain = REPLACE(domain, u0027http://www.your.old.domainu0027, u0027;",
        "UPDATE wp_blogs SET domain = REPLACE(domain, u0027http://www.your.old.domainu0027, u0027;"


  1. Give me a star =)
  2. Fork it
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Make your changes
  5. Commit your changes (git commit -am 'Added some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request