Wordpress host IP changed

前端 未结 7 1484
抹茶落季
抹茶落季 2020-12-08 00:32

I\'ve got a Wordpress site on our home intranet that has run into trouble now that the IP address has changed - The index page loads, but not the CSS and I can\'t log in to

相关标签:
7条回答
  • 2020-12-08 01:03

    I ran into this problem before when I was migrating a site from test to production. Conveniently, MySQL has a string replace function.

    Try something like this:

    UPDATE wp_posts SET post_content = REPLACE(post_content,"http://localhost","http://www.myblog.com")
    
    0 讨论(0)
  • 2020-12-08 01:09

    To temporarily be able to login, use this code in your wp-config.php:

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

    or you can add this to your theme's functions.php:

    update_option('siteurl','http://example.com/');
    update_option('home','http://example.com/');
    

    Warning: Updating the SQL database will be required in order for installed plugins to use the new URL/hostname. So if you use plugins modifying the database is required.

    0 讨论(0)
  • 2020-12-08 01:17

    Be careful for the link: https or http !!

    in the command line:

    mysql -u root -p
    

    in the SQL, set new IP for xxxx

    mysql> use wordpress;

    mysql> select * from wp_options where option_id=1;

    mysql> update wp_options set option_value="http://xxxx" where option_id=1; exit

    Restart server

    0 讨论(0)
  • 2020-12-08 01:22

    I ran into this problem once. Loginto your DB and check your wp_options (if wp_ is your table prefix) and then search for all records and replace your old ip with new.

    Possible columns to have the old ip would be 'permalinks' etc.. Sorry I cant see my blog's table structure now otherwise I would have posted the correct column name.

    0 讨论(0)
  • 2020-12-08 01:23

    You have to change the 'home' and 'siteurl' in the settings. Since you cannot open the admin side of wordpress, open the database in phpMyAdmin(or something similar).

    The options can be found in the 'wp_options' table(wp_ prefix might be different). Find the necessary setting using this query...

    SELECT * FROM `wp_options` WHERE `option_name` IN ('siteurl', 'home')
    

    Change the values of both the options to the new IP.

    0 讨论(0)
  • 2020-12-08 01:24

    You have two places to update this (well three, but we'll stick with the two).

    If you can still log into your admin section, type the following for your URI /wp-admin/options.php - so for example, if your site is http://localhost then your full URL will be http://localhost/wp-admin/options.php. Once you've logged into your site you should see two fields (well you'll see a lot of fields), but you'll want to look for the two with URL's in them - the Site URL and the Blog URL (in WP 2.7 the fields are labeled "home" and "siteurl", not sure on the other versions).

    Or, you can log into MySQL database and run the following.

    Select * from wp_options where option_name IN('siteurl','home'); 
    

    I just ran this today on one of my installs. If you're option_value is set to your localhost - you can then run the following:

    update wp_options set option_value='http://www.yourblogname.com' where option_name = 'siteurl';
    update wp_options set option_value='http://www.yourblogname.com' where option_name = 'home';
    

    This should update your table structure.

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