WordPress.org

Forums

Local Virtual Hosts (4 posts)

  1. brianpearce
    Member
    Posted 5 years ago #

    Hey Everyone,
    So I'm running wordpress locally on Mac OS 10.5.7 for development.
    I often use Virtual Machines (parallels/virtualBox) to run WinXP for testing layout etc. The problem is whenever I view my page from another computer on my network all the external files (js/css) break.

    If I view the source I can obviously see that the url to the documents is still pointing at my localhost.

    I'm using bloginfo('template_url'); ?>/c/style.css in my files and http://localhost/~myuser/mysite/wp-content/themes/themename/c/style.css is the resulting output. Shouldn't the output be reflecting the virtualHost address or remote ip address Im using to connect to the site?

    How can I get around this problem and make my site locally accessible to other unit on my network?

    Thanks,
    bp

  2. Meyway
    Member
    Posted 5 years ago #

    I think there is a solution (I hope to same problem you describe):

    So in my case: I have WIN-XP running inside VirtualBox. Trying to access a WordPress installation outside of the VirtualBox (Ubuntu-Host) by typing 10.0.2.2 inside the WinXP-Browser.

    This of course works fine - accept for the problem you describe: no theme seems to work. In fact, there seem to be many links with "localhost" hard coded in various places within the wordpress installations and add ons.

    Solution:
    1.) I installed xampp in WinXP.

    2.) Added a line to my Win-Hostfile (C:\WINDOWS\system32\drivers\etc\hosts) so that it looks like this:

    127.0.0.1 localhost
    10.0.2.2 outer

    3.) Simply added a .htaccess file to my ... /xampp/htdocs/ directory which contains only this line:
    Redirect / http://outer/

    Now when I enter "localhost" into my WinXP-Browser or whenever the browser comes accross a hard coded localhost-link it correctly maps (rather redirects) all "localhost" requests to "outer" which is resolved as 10.0.2.2 thru the host file.

    Of course I would have liked to simply map localhost to 10.0.2.2 in the host file (which doesn't work). But hey, the xampp-solution works fine for me.

  3. esger
    Member
    Posted 5 years ago #

    Many many MANY thanks to you!

    Been looking for a way to do this for days!

    Was also trying to find a way to simply map in the host file but for a reason I don't know, that doesn't work...

    Now, let's test and debug those websites for IE.. Doh!

  4. Meyway
    Member
    Posted 5 years ago #

    You're welcome. :)

Topic Closed

This topic has been closed to new replies.

About this Topic