Broken CSS after changing the site URL

I have a self-hosted WordPress blog on my home server. Previously I accessed it directly via its original IP address taken from DHCP, but now I have configured a static IP address for it. The problem is that now all the CSS is broken.

I have updated my wp-config.php file adding the following two lines:

define('WP_HOME','http://192.168.0.100/myblog/');
define('WP_SITEURL','http://192.168.0.100/myblog/');

and I have restarted apache, but the CSS is still broken. Is there some other configuration file that I should update?

5 Answers
5

If you have access to your mysql you can update the wp-options table.

Before modification…

$ mysql -u <db_user> --password=<db_pwd> -D <db_name> <<<"select * from wp_options where option_name in ('siteurl', 'home');"
+-----------+-----------------+---------------------------------------------------------------------------------------------------+----------+
| option_id | option_name     | option_value                                                                                      | autoload |
+-----------+-----------------+---------------------------------------------------------------------------------------------------+----------+
|         1 | siteurl         | http://172.17.0.2/wordpress                                                                       | yes      |
|         2 | home            | http://172.17.0.2/wordpress                                                                       | yes      |
+-----------+-----------------+---------------------------------------------------------------------------------------------------+----------+

Then I changed the ip to 172.17.0.4 with this…

$ mysql mysql -u <db_user> --password=<db_pwd> -D <db_name> <<<"update wp_options set option_value="http://172.17.0.4/wordpress" where option_name in ('siteurl', 'home');"    

So the table becomes…

+-----------+-----------------+---------------------------------------------------------------------------------------------------+----------+
| option_id | option_name     | option_value                                                                                      | autoload |
+-----------+-----------------+---------------------------------------------------------------------------------------------------+----------+
|         1 | siteurl         | http://172.17.0.4/wordpress                                                                       | yes      |
|         2 | home            | http://172.17.0.4/wordpress                                                                       | yes      |
+-----------+-----------------+---------------------------------------------------------------------------------------------------+----------+

In some scenarios it could be useful to automatically update this configuration.

Leave a Comment