If I move my WP installation I can hard code the IP address using
wp-config.php (codex here) but since I have 4 sites using subfolders I wanted to change one line instead of going to 4 files and change 8 lines. This solution is to use a file say
htdocs then insert below snippet in all 4
wp-config.php files to read the line containing the IP address in the text file.
$file = fopen(str_replace(substr(ABSPATH,-2),"",ABSPATH)."ip.txt", "r");
$ip = fgets($file);
In this example
/a/ is the subfolder containing a WP installation.
There are more issues than I ever anticipated. In fact WP uses absolute url for all attachments and media that went into the posts therefore if the sites are running under a different IP all links are broken. I have tried a few plugins which claim to resolve this, none of them can do all I want to do.
To completely replace IP addresses appear in all your posts I have to do it in mysql, fire up phpmyadmin then run below
UPDATE wp_posts SET post_content = REPLACE(post_content, 'xxx.xxx.xxx.old','xxx.xxx.xxx.new')
So that’s all I have to do to move my WP Intranet running under XAMPP portable Lite to an external drive, either thumb or HDD/SSD, run
setup_xampp.bat in the XAMPP root folder do the little tricks above then I could run the installation in any Windows OS.