Does anyone know of or have suggestions for how to go about setting up a WordPress url transformation script - perhaps via a plugin or one-time run script?
It would be used to correct installs which are deployed between each other and across servers and would need to work on network installs with unlimited sub-sites.
An example would be:
- Main site: install-one-main.com
- Sub site 2: install-one-sub-one.com
- Main site: install-two-main.com
- Sub site 2: install-two-sub-one.com
Network installs are more complex to update domain references in the db as they are stored in several tables - including numeric tables ( i.e wp_2_options ) created on the fly.
I am not looking for someone to write this solution for me - just hints, tips, ideas and if possible a link to an existing repo that will serve as a starting point.
Multisite is somewhat more complicated to move, as the database itself has multiple references to the server name as well as the folder locations. If you're simply moving to a new server with the same domain name, you can copy the files and database over, exactly as you would a traditional install.
If, instead, you are changing domains, then the best way to move Multisite is to move the files, edit the .htaccess and wp-config.php (change DOMAIN_CURRENT_SITE and, if the folder name containing Multisite changed, PATH_CURRENT_SITE), and then manually edit the database. Search for all instances of your domain name, and change them as needed. This step cannot yet be easily automated. It's safe to search/replace any of the wp_x_posts tables, however do not attempt blanket search/replace without the Search and Replace for WordPress Databases script (aka the interconnectit script).
If you're moving Multisite from one folder to another, you will need to make sure you edit the wp_blogs entries to change the folder name correctly. You should manually review both wp_site and wp_blogs regardless, to ensure all sites were changed correctly.
Also, manually review all the wp_x_options tables and look for three fields and edit them as needed:
If you are moving from subdomains to subfolders, or vice-versa, remember to adjust the .htaccess file and the value for SUBDOMAIN_INSTALL in your wp-config.php file accordingly