• I have a server on my home network running WordPress (just installed). On the server I use the URL http://localhost/blog, and that works. On my laptop I have to use the local address http://192.168.1.110/blog. In Firefox this forwards to http://localhost/blog and will not display. In I.E. I get 404 error. If I change the blog address in the General Options of the Dashboard the the actual web URL I can no longer view the page, Dashboard or anything, even on the server. Permissions are correct. Is there any other settings that may cause this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter gypsyjae

    (@gypsyjae)

    Apparently WordPress tries to resolve the URL, so once I set the blog so other’s can view it, I can no longer view it from within the network. I have to find a public network just so I can write to my own blog. I guess I will have to look for a better solution. Thanks. It looks good even if no one will ever see mine.

    Isn’t the local host http://127.0.0.1?

    Thread Starter gypsyjae

    (@gypsyjae)

    It is, but I don’t want localhost on my laptop. I want the address for the network server, which is determined by my router. The problem is that WordPress apparently tries to use that even for people who visit from the web, and if I change the setting in the Dashboard, then I cannot access the blog myself because I am behind the router. WordPress should be able to turn this off and just let my server do it’s job, but I can’t see that this is possible.

    So you are trying to say that
    i) you can only access the site at localhost or 127.0.0.1
    ii) other people access the site through http://192.168.1.110

    Do I get this correct?

    If so try this. It should work theoretically:
    1. Make sure that both localhost and 192.168.1.110 resolve to the same location

    2. Set the WordPress address and Blog address in General Options to http://localhost/

    3. Add the following code in the wp-config.php after the table_prefix line:

    $hostname = $_SERVER['SERVER_NAME'];
    $hostname = str_replace('www.', '', $hostname);
    if ($hostname == 'SecondDomain.com') {
    define('WP_SITEURL', 'http://192.168.1.110');
    define('WP_HOME', 'http://192.168.1.110');
    }
    Thread Starter gypsyjae

    (@gypsyjae)

    Thank you, that’s very close. On the server I use http://localhost/blog. On my laptop, not the server but still behind the router, I use http://192.168.1.110/blog. Everyone else from the internet uses http://myDomain.org/blog. The only one that works is localhost.

    So I guess ‘SecondDomain.com’ would be the actual web URL. Would I also replace ‘SERVER_NAME’, or is that a variable that I just didn’t recognize? I really appreciate the help. PHP is a foreign language to me.

    Whatever poppacket says… I have never seen a WP installation that works with both localhost AND an internet address. Forget it. A wise folk wisdom in my mother tongue says that you cannot sit with one ass in two saddles.

    Oh sorry, actually I just copied that code from another thread I post into. If you still wanna try this, despite whatever moshu said, try this:

    Assuming that you have successfully installed WP with:
    WordPress URL: http://localhost/blog
    Blog URL: http://localhost/blog

    Then put the following:

    $hostname = $_SERVER['SERVER_NAME'];
    $hostname = str_replace('www.', '', $hostname);
    if ($hostname == '192.168.1.110') {
    define('WP_SITEURL', 'http://192.168.1.110/blog');
    define('WP_HOME', 'http://192.168.1.110/blog');
    } elseif ($hostname == 'myDomain.org') {
    define('WP_SITEURL', 'http://myDomain.org/blog');
    define('WP_HOME', 'http://myDomain.org/blog');
    }

    The main idea is that, if one accesses your wordpress site at 192.168.1.110, WP will overwrite the original WordPress URL and Blog URL (in general options) to http://192.168.1.110/blog. Same goes if one access your WP site on myDomain.org. So you can actually access one single WordPress instance through three different URL.

    Well if this work, then you might wanna tell moshu. If it dont, it’s fine.

    it will prolly work, mainly due to the fact that those values can be set in 2.3.x (whatever version it was introduced in) and its a great introduction, if you ask me.

    And you need not to change SERVER_NAME, btw.

    jemgraves

    (@jemgraves)

    I wanted to post to confirm that this fix actually works. I’ve only been tearing my hair out all night over fixing it. I had to replace ‘192.168.1.110’ with ‘localhost’ in order to edit from my server. I imagine you’d have to add that to be able to access from all three places. Thanks, guys!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Blog Address’ is closed to new replies.