Change site URL and WordPress URL in Localhost

2019-03-17 02:05发布

问题:

I am work in Wordpress. And my system localhost url is http://localhost:8080/wordpress.
I want to shift our site another system.

My problem is that my another system localhost url is http://localhost/wordpress (not include 8080). So can you help me that is how many table update in our database

回答1:

I use the following queries to update domain name of the site

UPDATE wp_options
SET option_value = 'http://new-domain-name.com'
WHERE option_name = 'home';

UPDATE wp_options
SET option_value = 'http://new-domain-name.com'
WHERE option_name = 'siteurl';

UPDATE wp_posts
SET post_content = REPLACE(post_content,'http://old-domain-name.com','http://new-domain-name.com');

UPDATE wp_posts
SET guid = REPLACE(guid,'http://old-domain-name.com','http://new-domain-name.com');

Just change http://old-domain-name.com and http://new-domain-name.com to appropriate domain names. This should help you.



回答2:

Search replace db is a good tool to replace all old url with new urls. You can download latest file from

seach replace db

Perform following steps

  1. put the file on wp directory
  2. open wp config file and change database credentials
  3. open url in browser (http://localhost/wordpress/downloadedfile.php)
  4. read instruction and go to next step till it complete.

This tool help you to upload or migrate database from localhost to server or server to server.



回答3:

  1. Log in to your WordPress control panel (http://coolexample.com/wp-admin, where coolexample.com is your domain name).

  2. Click Settings, and then click General.

  3. In the WordPress address (URL) and Site address (URL) fields, enter the new domain name or URL you want to use, and then click Save Changes.

see: https://www.godaddy.com/help/changing-your-wordpress-domain-name-6495



回答4:

You have to be very careful about the search and replace and ensure that any serialized data in any of your tables is properly unpacked, updated and re-packed.

If your target site is usable you can use various things to update its data to use the new URL format.

If you're comfortable with the command line you can use the WP-CLI with a command like:

wp search-replace http://localhost:8080/wordpress http://localhost/wordpress

For a WordPress Admin Dashboard tool I'd recommend the free Better Search Replace plugin.

If the URL needs to be changed before loading the data into the new site's database, I'd recommend using the free WP Migrate DB plugin to export your database with a find/replace pair of "//localhost:8080/wordpress" and "//localhost/wordpress" (without quotes). You can then run the exported SQL file against your target site's database.



标签: wordpress