• Resolved cryora

    (@cryora)


    By default, the WordPress Address (URL) and Site Address (URL) is set to “https://localhost/html/”. This is a problem when someone other than the host tries to access the site, because “localhost” will refer to the client’s computer rather than the computer hosting the website.

    One way to resolve this is to enter my Computer Name instead of “localhost”, but the problem is I am using a Chromebook, which does not have a device name. I tried using my computer’s IP instead.

    I’ve edited the wp-config.php file to get WordPress to automatically change the WP_HOME and WP_SITEURL database options to my computer’s IP by adding the lines:

    $wordpress_url = $_SERVER[‘SERVER_ADDR’] . “/html”;
    define(“WP_HOME”, $wordpress_url);
    define(“WP_SITEURL”, $wordpress_url);

    This allows the front page to be visible, but all of the logos, posts, and pages cannot be found.

    When I try to enter wp-admin, I get this 404 message:

    ‘The requested URL /html/wp-admin/127.0.0.1/html/wp-login.php was not found on this server.’

    From a different device I get:

    ‘The requested URL 192.168.1.104/html/wp-admin/192.168.1.104/html/wp-login.php was not found on this server.’

    where 192.168.1.104 is my Chromebook’s network IP.

    I don’t get this problem if I leave the wp-config.php file unedited. , This means I would have to manually change the URL to my computer’s IP whenever I change networks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Dion

    (@diondesigns)

    $_SERVER[‘SERVER_ADDR’] only contains the domain name. You must also add the protocol (https:// or https://).

    EDIT: it appears there is a bug in the make_clickable() function. ??

    Thread Starter cryora

    (@cryora)

    Thanks that did the trick!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trying to automatically change the URL setting by editing wp-config.php’ is closed to new replies.