WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
1  
What are the addresses the stylesheets are being loaded from? – s_ha_dum Apr 22 '14 at 0:42
    
@s_ha_dum at the moment I am using the Twenty Thirteen theme and I haven't made any changes to it, so I would say everything is in the default theme folder. – user1301428 Apr 22 '14 at 11:37
1  
Have you updated the keys that you mention in the wp_options DB table? WP may still be looking for some resources at the old IP address. – David Gard Apr 22 '14 at 11:43
    
Didn't you change any file permissions. There was a similiar question on this here – Pieter Goosen Apr 22 '14 at 11:44
    
@DavidGard I haven't, but is it necessary? This page from the Codex seems to say that my edit should be enough: codex.wordpress.org/Changing_The_Site_URL – user1301428 Apr 22 '14 at 13:36

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.

share|improve this answer

The WordPress Codex 'Changing The Site URL' states the following -

Note: Both settings should include the http:// part and should not have a slash "/" at the end.

I notice in your question that both the WP_HOME and WP_SITEURL constants include the trailing slash. This means that the URL to your style-sheet will be in this format -

http://192.168.0.100/myblog//wp-content/themes/my-theme/style.css'

In short, remove the trailing slash from both declarations and it should fix the problem.

Note also that the aforementioned Codex states the following in relation to the solution that you have chosen.

This is not necessarily the best fix, it's just hardcoding the values into the site itself. You won't be able to edit them on the General settings page anymore when using this method.

I suggest using one of the other more permanent methods described to achieve your goal.

share|improve this answer
1  
Double slashes, though technically incorrect, still tend to work-- tested in five different browsers. I doubt this the problem. – s_ha_dum Apr 22 '14 at 14:37
    
@s_ha_dum - It depends on whether or not the URL has been rewritten. If it has, double slashes can still work (although not ideal). If not, essentially you are looking for a directory listing, so double slashes will not work. – David Gard Apr 22 '14 at 14:40
    
Stylesheet URLs are not rewritten, not by Core anyway, and that is exactly what I tested with-- I sent a direct request to the stylesheet URL. But I cannot find any combination of slashes that breaks requests on my server for any page, with or without permalinks (aka URL rewriting). If you know of some specific reproducible circumstances, please elaborate. – s_ha_dum Apr 22 '14 at 14:50
    
@s_ha_dum - I realise the stylesheet URL would not be broken, hence my reference to non-rewritten URLs. I'll do some testing now, as I'm sure I've come across issues with double slashes in the past... – David Gard Apr 22 '14 at 14:52
    
@s_ha_dum - Well I can't get double slashes to break my test site, so I guess I must have imagined that... However, my answer is still technically correct ;-) – David Gard Apr 22 '14 at 15:04
up vote -1 down vote accepted

For some reason, changing the URL from the GUI worked (after restoring the machine to the old IP address). Go figure.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.