Wordpress host IP changed

2019-01-21 16:30发布

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 the site administration panel.

Unfortunately I am a bit behind on backups. Is there a way to get Wordpress to refer to the new IP address?

标签: php wordpress
7条回答
疯言疯语
2楼-- · 2019-01-21 17:00

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

查看更多
放我归山
3楼-- · 2019-01-21 17:02

Possibly WordPress.org's coverage of this issue was not available at the time the other answers here were written, but as of now I find it more complete and easier to follow.

In my case, the method of modifying wp-config.php was only partially successful. The Relocate method described in the above web page ultimately succeeded.

Here is a synopsis of WordPress.org's coverage:

1 Changing the Site URL
    1.1 Edit wp-config.php
    1.2 Edit functions.php
    1.3 Relocate method
        1.3.1 Code function
        1.3.2 Steps
    1.4 Changing the URL directly in the database
2 Moving Sites
    2.1 Altering Table Prefixes
    2.2 Changing Template Files
    2.3 Changing the Config file
    2.4 Verify the Profile
    2.5 Changing the .htaccess file
    2.6 Additional items of note
        2.6.1 Important GUID Note
    2.7 Multi-site notes
    2.8 wp-cli
查看更多
Anthone
4楼-- · 2019-01-21 17:04

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")
查看更多
姐就是有狂的资本
5楼-- · 2019-01-21 17:05

If you don't want to hack the database directly, 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/');
查看更多
老娘就宠你
6楼-- · 2019-01-21 17:12

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.

查看更多
小情绪 Triste *
7楼-- · 2019-01-21 17:15

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.

查看更多
登录 后发表回答