15

I am working in Wordpress, and my system localhost URL is http://localhost:8080/wordpress.
I want to move our site to another system.

My problem is that my other system's localhost URL is http://localhost/wordpress (it does not include port 8080).

Can you help me with this, or tell me how to update the tables in our database?

7 Answers 7

38

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This is very nicely written and super easy to read. I've adapted your code in an answer here and linked it back to you.
12

Fastest and best way to change the URL is to go to the wp-config.php File and place this code:

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

2 Comments

Looks better! It is recommended when using pretty urls
Does that change the values in the database?
2

This are the steps, what I have done to make it success !,

1. Change the root folder name from \htdocs\OldSiteName to \htdocs\NewSiteName .

2. Change the wp-config.php

From,

    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/OldSiteName');
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/OldSiteName');

To,

   define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/NewSiteName');
   define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/NewSiteName');

3. Change the content in the .htaccess file

From,

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /OldSiteName/
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . /OldSiteName/index.php [L]
</IfModule>

To,

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /NewSiteName/
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . /NewSiteName/index.php [L]
</IfModule>

4. Execute the scripts to change the values in the database.

UPDATE wp_options 
SET option_value = 'http://127.0.0.1/NewSiteName' 
WHERE option_name = 'home';

UPDATE wp_options
SET option_value = 'http://127.0.0.1/NewSiteName'
WHERE option_name = 'siteurl';

UPDATE wp_posts
SET post_content = REPLACE(post_content,'http://127.0.0.1/OldSiteName','http://127.0.0.1/NewSiteName');

UPDATE wp_posts
SET guid = REPLACE(guid,'http://127.0.0.1/OldSiteName','http://127.0.0.1/NewSiteName');

These are all the steps that I have done to make all the pages and inter links to get worked. eg: Clicking menu should take it the correct page.

Note : Reference link : https://wordpress.org/support/article/changing-the-site-url/

Comments

1
  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

Comments

1

If you're using WPbakery (or not) then you should use this: GoLive

I can confirm that this is working perfectly!

Comments

0

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.