WordPress Url Change Database SQL Query

First I query the current website url in the db…

SELECT *  FROM wp_options  WHERE option_name = 'home' OR option_name = 'siteurl';

Then I replace the current.website.url with the value from the previous query and replace new.website.url with the new url value in the query below (exclude the http prefixes)…

UPDATE wp_posts SET guid = replace(guid, 'current.website.url','new.website.url');
UPDATE wp_posts SET post_content = replace(post_content, 'current.website.url','new.website.url');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'current.website.url','new.website.url');
UPDATE wp_options SET option_value = replace(option_value, 'current.website.url','new.website.url') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_usermeta SET meta_value = replace(meta_value, 'current.website.url','new.website.url');

How to Setup Local LAN Web Site Testing

If it’s a WordPress site don’t forget to change the .htaccess base directory if you’re using the ip address… i.e. for 192.168..1.1/wpsite/….

# BEGIN WordPress

RewriteEngine On
RewriteBase /wpsite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpsite/index.php [L]

# END WordPress

Accessing Websites on a Local Network (LAN) Web Server

Copy Synch Remote Directories in Linux with Rsync

The best command i use to recursively copy remote directories between servers…

rsync -avz -e ssh username@server_ip_or_Name:full_system_directory_of_remote_files local_destination_dir

Rsync with an ssh identity file…

rsync -avz -e 'ssh -i /path/to/id_rsa' username@server_ip_or_Name:full_system_directory_of_remote_files local_destination_dir

How to Setup Rsync with SSH on UNIX / Linux

How to Backup Linux? 15 rsync Command

Specify identity file (id_rsa) with rsync

Using Rsync and SSH: Keys, Validating, and Automation