vikal singh
vikal singh

Reputation: 151

Change site URL and WordPress URL in Localhost

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

Upvotes: 15

Views: 70825

Answers (7)

Waleed Muaz
Waleed Muaz

Reputation: 800

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');

Upvotes: 12

Seppe Beelprez
Seppe Beelprez

Reputation: 429

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

I can confirm that this is working perfectly!

Upvotes: 1

Anand
Anand

Reputation: 61

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/

Upvotes: 2

ianmjones
ianmjones

Reputation: 3415

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.

Upvotes: 0

Marco Rubio
Marco Rubio

Reputation: 71

  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

Upvotes: 1

Manish Shukla
Manish Shukla

Reputation: 1365

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.

Upvotes: 0

iurii
iurii

Reputation: 4230

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.

Upvotes: 38

Related Questions