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)…

SET SQL_SAFE_UPDATES=0;
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');
SET SQL_SAFE_UPDATES=1;

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