Change site URL and WordPress URL in Localhost

后端 未结 7 1209
温柔的废话
温柔的废话 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: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,

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

    To,

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

    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/

提交回复
热议问题