Change site URL and WordPress URL in Localhost

后端 未结 7 1182
温柔的废话
温柔的废话 2020-12-05 06:02

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 sy

相关标签:
7条回答
  • 2020-12-05 06:20

    Fastest and Best Way to Change Go to WP-Config File and place that code

    define('WP_HOME','http://example.com');
    define('WP_SITEURL','http://example.com');
    
    0 讨论(0)
  • 2020-12-05 06:23

    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.

    0 讨论(0)
  • 2020-12-05 06: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.

    0 讨论(0)
  • 2020-12-05 06:39

    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.

    0 讨论(0)
  • 2020-12-05 06:42

    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/

    0 讨论(0)
  • 2020-12-05 06:46

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

    I can confirm that this is working perfectly!

    0 讨论(0)
提交回复
热议问题