• I have xampp running on my laptop so I can run a localhost copy of my website https://whs59.net. But when I click Recent Comments, any category, or the monthly archives I end up online. I want to stay local and can’t figure out how to do so. I can’t find any suspicious references to whs59.net anywhere in c:/$LOCALHOST/xampp or a subdirectory of same. Can anyone enlighten me as to what’s going on? I suspect that something defines ‘url’ or ‘siteurl’ or somesuch as whs59.net, but that’s just a wild guess.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The value is defined in your database. This guide explains how to change it if you can’t get to the options page:

    https://www.tamba2.org.uk/wordpress/site-url/

    I’m assuming your localhost version has the local database set in wp-config.php

    Thread Starter geraldisaacs

    (@geraldisaacs)

    Thanks for your help. However I need a little more info to proceed.

    The url for my site homepage in localhost mode shows as:
    https://localhost/wordpress/?page_id=46

    My directory structure is
    c:\$LOCALHOST\xampp\htdocs\wordpress\…

    The online url for the homepage shows as:
    https://whs59.net/wordpress/?page_id=46

    my wp-config.php file is:

    —————————————————-
    // ** MySQL settings ** //
    define(‘DB_NAME’, ‘wordpress’); // The name of the database
    define(‘DB_USER’, ‘root’); // Your MySQL username
    define(‘DB_PASSWORD’, ”); // …and password
    define(‘DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value

    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!

    // Change this to localize WordPress. A corresponding MO file for the
    // chosen language must be installed to wp-includes/languages.
    // For example, install de.mo to wp-includes/languages and set WPLANG to ‘de’
    // to enable German language support.
    define (‘WPLANG’, ”);

    /* That’s all, stop editing! Happy blogging. */

    define(‘ABSPATH’, dirname(__FILE__).’/’);
    require_once(ABSPATH.’wp-settings.php’);
    ?>
    ———————————————————

    I haven’t checked yet to see the values of ‘home’ and ‘siteurl’ but would be glad to check if you can tell me beforehand what the values should be to allow local access to the comment pages, etc.

    Thanks in advance for any additional help you might be able to provide.

    You could rename your computer (127.0.0.1) to whs59.net in the hosts file. Also, make sure that your laptop does not change its name automatically using dhcp when you test your site locally.

    Thread Starter geraldisaacs

    (@geraldisaacs)

    Attempting to follow the idea suggested by LostInNetwork, I renamed my computer in the c:\i386\hosts file (changed localhost to whs59.net). Rebooted and checked that name in hosts file did not change.

    Turned off internet connection and started site in local mode; it fired up ok except that it obviously lacked any communication with style.css.

    So I assumed I needed to change my wp-config.php file from
    define(‘DB_NAME’, ‘wordpress’);
    to
    define(‘DB_NAME’, ‘whs59.net’);

    which resulted in various errors. (Can’t find site, wrong password, 404, etc)

    Am I on the right track yet? What files do I need to re-reference? Does every reference in c:\$LOCALHOST and its subdirectories need to be changed from ‘localhost’ to ‘whs59.net’? Thanks for any help you can provide.

    If you’re running windows xp (probably true for other windows versions too), the hosts file is present at C:\\WINDOWS\\SYSTEM32\\DRIVERS\\ETC\\HOSTS

    Thread Starter geraldisaacs

    (@geraldisaacs)

    Changed wp-config.php back to original setting with the following line:

    define(‘DB_HOST’, ‘localhost’);

    Changed both hosts files to reflect new computer name whs59.net – don’t know which one is necessary (or maybe both)

    Have to access local site initially as https://localhost/whs59.net

    Then if I click on any links to categories, the local version prevails, although the url box shows https://whs59.net/…

    Then if I click back to home, the url shows as https://whs59.net/…, which surprises me because my connection is still local, as it should be. (An initial key-in to this url would take me straight to the internet or would bomb if I had disconnected my wireless link.)

    So the problem is nearly resolved. One issue remains. When I try to access the internet site from this computer (the one that hosts the local site) with https://whs59.net, the url box immediately changes to https://whs59.net/xampp/ and sends me a 404 error.

    If I access it as https://www.whs59.net everything seems to work ok.

    This is a trivial problem with an easy workaround (change my desktop icon link to include www.), but I would appreciate a brief explanation of what’s going on, if someone would be so kind.

    Thanks

    Thread Starter geraldisaacs

    (@geraldisaacs)

    On second thought it’s not trivial at all. It appears that now I cannot get full internet access to the website from the localhost computer because every time I click on a category (or any sidebar-linked page) from the internet website, it throws me back to the localhost page instead of the internet page. Maybe renaming the localhost computer whs59.net is not such a good idea after all. It kinda reverses my original problem. Now I cant access the internet website from this computer. Any suggestions out there?

    c:\i386 is a place for install/recovery files. It’s not a part of the operating system file structure. Like Pravin told, the hosts file is somewhere under c:\windows.

    If you edit hosts and disable dhcp, your computer will BE whs59.net. You should also note, that if you use http: in the urls then http will be used for connections and you do need a webserver.

    It might be a good habit to replace “https://whs59.net” with “$WEBSERVERROOT” or something. Then your system can be ported to other domains, and you could easily make it “file://path/” for local use and testing.

    Thread Starter geraldisaacs

    (@geraldisaacs)

    Let me recap my problem and objective, and maybe someone can tell me if it is reasonably easy to accomplish my aim.

    I finally have a sorta-working copy of my website on a flashdrive. I use xampplite. I can access my local site via http:/localhost/wordpress. I can then move around from the homepage to various other pages and stay local, but as soon as I click a link to a comment, I go online instead of staying local. I want to stay local. I would like to edit pages, comments, etc. without going online. I would like to be able to transfer mods to the online host via FTP. I would also like to be able to localhost-demo the whole site to others when internet access is impossible.

    But as soon as I try to login or click any comment, the computer goes online (or gives me 404s if there is no internet connection). Can I fix this? That is, can I access the site locally or online at will from this computer without having to reconfigure stuff back and forth?

    BTW, I did not understand the previous comment about $WEBSERVERROOT and file//path. My online url is https://whs59.net. My local access is https://localhost/wordpress. Please understand that I am not code-proficient in HTML, Java, php, whatever. I am willing to mess with MySQL and Apache and all these other MyWhatever things, but the exercise is not very comfortable. It has taken me about three weeks to get the local website copy to work at all.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘localhost goes online’ is closed to new replies.