SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict iwonder's Avatar
    Join Date
    Feb 2005
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing IP of localhost

    I need to change the localhost to a IP address in Windows XP. i.e when I open localhost/ it should display content of the IP but the name/url should be localhost.

    The thing is, I am using a virtual machine, Parallels Desktop, on mac to run windows. So to access the mac localhost on xp, I have to go to a IP address, but when I do, although it displays the page of the mac localhost, all the stylesheet and image links are still localhost/url so only text is shown, the rest leads to a 404 page.

    i.e If I go to the IP which has this html page. The content is like this

    HTML Code:
    <html>
    <body>
    <head>
    <title>A Title</title>
    <link rel="stylesheet" type="text/css" href="localhost/url/style.css" />
    </head>
     ......
    The stylesheet does not open as it is from localhost/ url.

    (Hope this is the right forum .)

  2. #2
    SitePoint Member captaincarne's Avatar
    Join Date
    Dec 2008
    Location
    Las Vegas, NV
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which OS is running your web site? Mac or XP?

    It sounds like you are trying to test your site from your XP VM and your Mac has the files for your site. If so, you may need to create a Shard Folder (VMware has this, not sure if Parallels does) to access the files. You shouldn't need a reference to the hostname.

    Code:
    <html>
    <body>
    <head>
    <title>A Title</title>
    <link rel="stylesheet" type="text/css" href="url/style.css" />
    </head>
     ......

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2007
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can just change the tcp/ip address in your network settings

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    localhost is pre-defined to point to 127.0.0.1 so if you need to point to a different ip address then you can't use localhost.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Addict iwonder's Avatar
    Join Date
    Feb 2005
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to run the php files which are connected to a mysql all working on localhost (of Mac OSx ) and access it from the windows virtual machine on its localhost url . The whole point is to test the script/design on Internet Explorer.

    GFXedit DesignsFree/Custom CSS Designs & Wordpress themes
    Web 2.0 & Me | Personal Blog | IndianWebDevs | AutoPundit |

  6. #6
    <?php while(!sleep()){code();} G.Schuster's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems as if you can not change localhost but you could use relative links in your scripts.

    <link rel="stylesheet" type="text/css" href="localhost/url/style.css"/>
    Well...this is wrong in all cases.
    Either reference it as real URL (http://the.real.ip/url/style.css) or just as relative URL (/url/style.css).
    The latter should work fine as when you browse the site by the IP the browser automatically extends it to http://the.current.ip/url/style.css

  7. #7
    SitePoint Member captaincarne's Avatar
    Join Date
    Dec 2008
    Location
    Las Vegas, NV
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will need to access the site from your XP VM with the IP address of your Mac.

    Mac = 192.168.1.1
    XP = 192.168.1.2

    Use http://192.168.1.1 to access the web server on your Mac from your XP VM.

  8. #8
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    C:\Windows\System32\drivers\etc Open the "hosts" file change the IP address located in front of "localhost" save, done.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •