WordPress.org

Ready to get started?Download WordPress

Forums

Local Host \ Online Hack (12 posts)

  1. Direkt
    Member
    Posted 8 years ago #

    Evidently the coders of WordPress, never assumed that I would like to host WordPress from a machine and use it on that very same machine. Now, I know there a serious reprecussions of dealing with the matter this way, but I decided that it would work well enough for my purposes.

    Place this code inside of your get_settings() function in the function.php file of WordPress.

    // Allow Local & Online Viewing
    if ( 'siteurl' == $setting || 'home' == $setting ) {
    $ip = $_SERVER['REMOTE_ADDR'];

    if ('127.0.0.1' == $ip) {
    $value = 'http://localhost';
    } else {
    $value = 'online url';
    }
    }

    The best idea for your viewers would be to make your default siteurl in your options to the online URI, so that way they can get all the benefits, while you get basic access, just enough to play around though. I'll eventually make a more extensive hack to give the same online abilities to local, and hell, if I can figure out how I can manage it, I might make it a a plugin.

  2. tetktetter
    Member
    Posted 8 years ago #

    Hi, Direkt,

    I have the same problem. So I want to install this feature. But where is "function.php" in WordPress ?? Also see my discussions under "side bar is main screen
    Ties

  3. Direkt
    Member
    Posted 8 years ago #

    Yeah, nice to see another self-hoster around these parts. It's located in your wp-includes function. But I expierenced that anything that requires you to pull the site url from the MySQL database generally outputs your set site url. I plan to make a better and manageable hack for it.

  4. tetktetter
    Member
    Posted 8 years ago #

    I hope you will post it then or mail me at tiko.proj@wxs.nl if it takes longtime

  5. Direkt
    Member
    Posted 8 years ago #

    Hopefully I can make a quick fix for this, but there are no guarentees.

  6. Direkt
    Member
    Posted 8 years ago #

    Alright, I've made a cleaner hack this time, and it removes most ( if not all ) of the reprecussions you'd get from doing my method mention above. I've made a nice .ZIP file for you Windows users, but I'd really also like if you'd host it on your own site if it proves rather useful.

    http://iwni.selfip.net/loc-on.zip

  7. bob58
    Member
    Posted 8 years ago #

    Mmmm, ever thought about changing the etc/hosts file on your machine, so that 'online url' links to 127.0.0.1 ?

    As far as I got it, you'd only like your system to be available from your machine as well as from the internet. Adding that part to the hosts file, it is treated like a DNS entry and your machine connects to itself without using the internet connection.

    The hosts file is in Unix under /etc/hosts and in Windows under %WIN_DIR%/system32/drivers/etc/hosts ...

  8. tetktetter
    Member
    Posted 8 years ago #

    Hi, all, Well I will try all proposed items. Let you know.... Why is it always getting late....or better: early in front of the pc

  9. tetktetter
    Member
    Posted 8 years ago #

    Ok, the hack from Direkt works OK, so, I'm happy. Let's study further. Thanks Direkt. Bob58: I run WordPress on Win98SEII, so could not find your trick, so could not try it

    Best regards

    Ties

  10. jaredquinn
    Member
    Posted 8 years ago #

    On Windows boxen the hosts file lives somewhere silly like:

    \WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS.TXT

    But bob58 really has the right idea, your machine should answer to the name of the host locally as well as from the internet.

  11. ThePawSpa
    Member
    Posted 8 years ago #

    It takes a whole 5 mins to run WP on your computer via this: So yes, someone already thought people would like to run WP on their own computer

    http://www.urbangiraffe.com/2005/05/22/installing-wordpress-on-your-own-windows-computer/

  12. briceb
    Member
    Posted 8 years ago #

    Sounds like "LOCALHOST" is not resolving... this hack is kludge. Fix the problem underneath...

Topic Closed

This topic has been closed to new replies.

About this Topic