How to eliminate need for "localhost" prefix in Edge, localhosted site

Page 2 of 2 FirstFirst 12

  1. Posts : 609
    W10
       #11

    I really mean the HOSTS file of Windows, not the Virtual Host configuation. My guess is that in Edge it will continue working without the entry from the HOSTS file, while it should then no longer work in all other browsers. If this is the case, then it means that Edge does not honor the HOSTS file at all. It then does not matter what you put in there; Edge will just ignore it.
      My Computer


  2. Posts : 7
    Windows 10 Pro
    Thread Starter
       #12

    Nope, that makes no difference. When I explicitly rem-out the localhost entry in the Windows HOSTS file, like this:

    Code:
    #127.0.0.1     localhost
    ...then my sites run on Edge with the 'localhost/' prefix, and they run without the 'localhost/' prefix on Chrome, Firefox, even IE11, and all the other browsers.

    In fact, I had put the "127.0.0.1 localhost" entry in the Windows HOSTS file without any need to, because at the top of the file, in the default commentary that Microsoft puts in the file explaining to the user how to use the file, there is found the following remarks by Microsoft:

    # localhost name resolution is handled within DNS itself.
    # 127.0.0.1 localhost
    # ::1 localhost

    So, Microsoft there is explaining it's unnecessary to have a 'localhost' entry for 127.0.0.1 in its HOSTS file, as that's handled internally by the OS. And that's why my localhosted sites continue to run in the fashion I've described.

    Also, I tried to override the localhost definition by putting in a different one:

    Code:
    205.251.242.54		localhost
    ...but that doesn't work...the OS apparently ignores whatever definition you assign explicitly to localhost in the Windows HOSTS file and instead uses 127.0.0.1 exclusively, so there's never been a need for me even to have that definition in the Windows HOSTS file. (205.251.242.54 is the IP for Amazon.com, BTW...and I tried other IP addresses including nonsensical ones as well, so that pretty much proves it.)

    How about setting up the current version of XAMPP, configuring as I described above (with the correct definitions in the HTTPD-VHOSTS.CONF as I corrected it above, with 'htdocs/' in between 'localhost/' and 'mysite/', etc.), and see if you don't get the same results I'm getting.
      My Computer


  3. Posts : 609
    W10
       #13

    TomXampp said:
    In fact, I had put the "127.0.0.1 localhost" entry in the Windows HOSTS file without any need to, because at the top of the file, in the default commentary that Microsoft puts in the file explaining to the user how to use the file, there is found the following remarks by Microsoft:

    # localhost name resolution is handled within DNS itself.
    # 127.0.0.1 localhost
    # ::1 localhost

    So, Microsoft there is explaining it's unnecessary to have a 'localhost' entry for 127.0.0.1 in its HOSTS file, as that's handled internally by the OS. And that's why my localhosted sites continue to run in the fashion I've described.
    Thanks for clearing that up. This means, localhost is a special case, which makes it a bad example...

    I have now tried configuring a few IPs in my HOSTS file, for example I set the IP of my router, gave it the name "router" and I now can open it using this name, also in Edge.
      My Computer


  4. Posts : 7
    Windows 10 Pro
    Thread Starter
       #14

    Okay, just to ensure I understand you, you mean that you can go to a locally hosted site just by putting the site name in the URL bar without prefixing it with 'localhost/', in other words, you can go to a site named 'router' by putting:

    Code:
    router/
    ...in your URL bar in Edge, not:

    Code:
    localhost/router/
    Is that correct? If so, could you please share with me (i.e. post here) the settings you put in your Windows HOSTS file as well as the configuration in the XAMPP HTTPD-VHOSTS.CONF file so I can try to duplicate your result in Edge and the other browsers?
      My Computer


  5. Posts : 609
    W10
       #15

    Entering the IP of my router inside the HOSTS file just was the first step for me to see, if Edge would generally obey the HOSTS file. It does. :) I can access the router now by simply typing "router", without "locahost/" in front of it, inside the address bar. Note however, that this router is in my local network, but it is not localhost.

    I'll see, if I can get it running with XAMPP...
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:52.
Find Us




Windows 10 Forums