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

Discus and support How to eliminate need for "localhost" prefix in Edge, localhosted site in Browsers and Email to solve the problem; Elsewhere in these forums it has been explained that for a localhost site to run in Edge, the Developer's Settings Use Microsoft Compatibility Lists... Discussion in 'Browsers and Email' started by TomXampp, Oct 17, 2015.

  1. TomXampp Win User

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

    Elsewhere in these forums it has been explained that for a localhost site to run in Edge, the Developer's Settings Use Microsoft Compatibility Lists and Allow Localhost Loopback should both be checked to be active. I have done that and I can use XAMPP for accessing the root of my localhost.

    However, there is a specific problem that hasn't been addressed, and one that prevents relative paths in my site to be accessed on Edge.

    First, please understand that my site runs in Edge when served from a live server. There's no problem there.

    Second, please understand that I can in fact get to the index.php of the main folder of my sites on localhost, but with one caveat, and that is the source of all of the other problems:

    --> In Edge, localhosted sites apparently (?) must be prefixed with 'localhost/' in order to be found and executed.

    This means that if I have a site called "mysite1", I cannot simply put "mysite1/" in the URL bar of Edge to access it. Instead, I must prefix it with 'localhost/', like this: "localhost/mysite1/". Then and only then will Edge find the index.php in the mysite1 folder and proceed.

    BUT: This means all relative path statements will not resolve correctly. For example, in my HTACCESS file, I have this MOD Rewrite directive:

    Code: RewriteRule ^info/?$ /info.php [L][/quote]
    This means that I can href info.php in the root of my site simply by using 'info'. However, because Edge insists on prefixing the URL with 'localhost/', a call to /info.php looks for it in the 'localhost/' directory, not the 'localhost/mysite1/' directory, and therefore it fails. This is also true for a simple HREF that calls '/index.php'. The only way around it is to put a dot before the slash, like this: './index.php'.

    I need to learn what configuration should be used to eliminate the need for prefixing localhosted sites with 'localhost/'

    All other browsers support my localhosted sites and serve them just by putting 'mysite1/', etc., in the URL bar. Edge seems to require a prefix of 'localhost/', thus 'localhost/mysite1'. I need to eliminate that requirement so that relative paths in my site code do not malfunction.

    I am using the current version of XAMPP.

    My C:\xampp\htdocs\ folder is shared with Administrator and with full permissions granted.

    In C:\Windows\System32\drivers\etc\hosts I have:

    Code: localhost mysite1 mysite2[/quote] etc.

    And in C:\xampp\apache\conf\extra\http-vhosts.conf I have:

    Code: <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs" ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/mysite1" ServerName mysite1 </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/mysite2" ServerName mysite2 </VirtualHost>[/quote] etc.

    This allows me to run either localhost, mysite1, or mysite2 by putting in a browser's URL bar respectively (except in Edge):

    Code: localhost/ mysite1/ mysite2/[/quote] This is my system setup and configuration, in case that is relevant. What settings do I need to apply to Edge in Windows 10 to eliminate the requirement for a prefix of 'localhost/' before the name of each of my localhosted sites?

    TomXampp, Oct 17, 2015

  2. IIS won't run on Win 10 Home (Localhost not connecting)

    I'm trying to run IIS on Windows 10 Home.

    I've already gone to the Control Panel and turned on the IIS Management Console on the Windows Features, but when I go to http://localhost/ I

    I've looked on multiple sites and checked stackoverflow and haven't found anything that answers this issue. The sites just say: "Check the box", run the service and then verify that it works by going to http://localhost.

    Is there something more that I need to do?
    David K. - Chicago, Oct 17, 2015
  3. LarsRiewe Win User
    Windows 10 MS Edge browser Windows Authentication Negotiation is not being done

    NTLM still not working in Edge / Win10. We keep getting only the first 401, but no "negotiating" follows. Works with IE 11, Chrome, Firefox. We tried real hostname and localhost, both included nn intranet sites. We need a fix very soon!
    LarsRiewe, Oct 17, 2015
  4. Joergi Win User

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

    Let me summarize:

    You have a website, which works correctly, if accessed through its URL, but which does not work, when you try to run it from your local PC when using Edge. This is a problem in Edge; it is working correctly with all other browsers.
    You have configured virtual hosts for localhost/ and for mysite1/. In Edge, you also can access the first by typing localhost/, but typing mysite1/ does not work.

    And that leaves me kind of clueless. Obviously this is not a problem in your website or in your virtual host configuration, but a problem in Edge.

    Is it maybe impossible to access other local sites than localhost/ with Edge? Would not be the first missing feature in that browser...
    Joergi, Oct 18, 2015
  5. Joergi Win User
    Does Edge maybe have some kind of developer tools? Inspecting them might give you more information on what Edge thinks is going wrong. Some kind of error message would be great...
    Joergi, Oct 18, 2015
  6. TomXampp Win User
    Your summary of my problem is accurate except for one detail: I can run localhost sites so long as I prefix their address with 'localhost', like this:

    Code: localhost\mysite\[/quote] That works. This does not:

    Code: mysite\[/quote] On all other browsers, I can access localhost sites just by putting the site name into the URL bar:

    Code: mysite\[/quote] On Edge, a localhost site MUST be prefixed with 'localhost\', like this:

    Code: localhost\mysite\[/quote] This causes a problem with relative paths. If I have a file in the root of mysite named info.php, I can access it anywhere in the site by an href of:

    Code: \info.php[/quote] The initial slash take you to the root of the URL. On all other browsers, since the root is mysite\, '\info.php' accesses:

    Code: mysite\info.php[/quote] ...because 'mysite\' is the root. However, because Edge by default requires that the URL be prefixed with 'localhost\', localhost becomes the root. Thus, an href to '\info.php' means the site code looks not to mysite\ but instead to 'localhost\', since 'localhost\' is the root of the URL. In other words, it looks for info.php here:

    Code: localhost\info.php[/quote] And that's not where the info.php is kept. It's in 'mysite'. Therefore a 404 error is generated, for the file is not found when it is referenced with '\info.php'.

    If Edge did not require the URLs of localhosted sites to be prefixed with 'localhost\', this problem would vanish.

    It's important to understand that those same localhosted sites work perfectly in Edge when served from a live server, as 'mysite\', etc., is the defacto root in those cases.

    Please let me know if you need additional clarification.
    TomXampp, Oct 18, 2015
  7. Joergi Win User
    It surely is possible to adjust the Apache configuration in such a way that URLs requesting localhost/mysite1/ internally get rewritten to folder mysite1/. Possibilities might be mod_rewrite with RewriteRules or mod_alias with a Redirect. All that will only change the symptoms, but not the cause of the issue.

    In Insider Builds, prior to the release of Windows 10, Edge was unable to display local websites all together and it was a feature when Microsoft implemented support for localhost/.

    I have just done a small test on that and for me, it also does not work: It's OK with localhost, but not with other domains. I think Edge does not use the hosts file at all. Can you still see pages under localhost/, if you remove the localhost from the hosts file?
    Maybe using other local domains currently really is not possible.

    You could however configure Apache to listen on a different port for one of the sites. That way you could then access it using that port, e.g. as localhost:1234 (Not sure, if Edge supports that, but worth a try...)
    Joergi, Oct 18, 2015
  8. TomXampp Win User

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

    I just realized a typo I made in the description of my httpd-vhosts.conf file. I neglected to add "htdocs" between "xampp" and "mysite1"/"mysite2" in the description of the file. I'm not sure if this has any bearing on your understanding of the problem and the responses you've provided, but just in case, I felt the need to report this oversight. Here's how the config file should appear.

    Code: <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs" ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/mysite1" ServerName mysite1 </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/mysite2" ServerName mysite2 </VirtualHost>[/quote] I've corrected this in the original posting.
    TomXampp, Oct 19, 2015
  9. Joergi Win User
    I see.

    Have you tried removing localhost from your hosts file? Can you still access files on localhost in Edge afterwards?
    Joergi, Oct 19, 2015
  10. TomXampp Win User
    I have now tried doing that, but my sites won't work correctly unless the localhost is defined in both the Windows hosts file and in the XAMPP httpd-vhosts.conf file.
    TomXampp, Oct 19, 2015
  11. Joergi Win User
    Have you also tested that with Edge?
    Joergi, Oct 20, 2015
  12. TomXampp Win User
    Of course, that's the browser that has the problem.

    Disabling the localhost identification in the httpd-vhosts.conf file of Apache in XAMPP prevents the site from running altogether. Specifically, I mean remming-out this code, like this:

    Code: #<VirtualHost *:80> # DocumentRoot "C:/xampp/htdocs" # ServerName localhost #</VirtualHost>[/quote] Doing that prevents the site from running entirely. On the other hand, it's not necessary to rem-out the localhost definition in the Windows HOSTS file:

    Code: localhost[/quote] that is handled by the DNS internally.

    So, there's that piece of the puzzle. And it remains a puzzle.

    The issue is simply that Edge requires locally-hosted sites to be prefixed by "localhost/" in their URL address. While that clarifies to the reader that the site is, in fact, coming from a localhost and not the web, it creates the potential for relative path confusion, as the root of each site must be spelled out to avoid confusion with the localhost/ root. (I hope that makes sense.)
    TomXampp, Oct 20, 2015
  13. Joergi Win User

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

    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.
    Joergi, Oct 20, 2015
  14. TomXampp Win User
    Nope, that makes no difference. When I explicitly rem-out the localhost entry in the Windows HOSTS file, like this:

    Code: # localhost[/quote] ...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 " 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.
    # localhost
    # ::1 localhost

    So, Microsoft there is explaining it's unnecessary to have a 'localhost' entry for 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: localhost[/quote] ...but that doesn't work...the OS apparently ignores whatever definition you assign explicitly to localhost in the Windows HOSTS file and instead uses exclusively, so there's never been a need for me even to have that definition in the Windows HOSTS file. ( is the IP for, 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.
    TomXampp, Oct 20, 2015
  15. Joergi Win User
    Thanks for clearing that up. This means, localhost is a special case, which makes it a bad example... *cry

    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.
    Joergi, Oct 20, 2015

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

  1. How to eliminate need for "localhost" prefix in Edge, localhosted site - Similar Threads - eliminate need localhost

  2. localhost

    in Windows 10 Customization
    localhost: Hello I am using xampp to set up my own web server. My problem is I think, not being able to access port 80, which I think is related to iisrid. Anyway if any one knows what is happening here and has any suggestions would be appreciated[ATTACH]...
  3. localhost missing

    in Windows 10 Support
    localhost missing: For many years I have used a program called get_iplayer which downloads BBC TV programmes. When the programme has been selected get_iplayer starts with: "Listening on" Now it has just started issuing the following message: http://localhost:1935 Application...
  4. Localhost 404 Errors

    in Windows 10 Network and Sharing
    Localhost 404 Errors: Last night, I upgraded my Windows 10 Pro to Version 1903 (OS Build 18362.267). Now my localhost applications don't work. They're either saying they can't establish a connection, or are giving 404 errors. For example, I run a Minecraft Server on Multicraft, which calls for...
  5. localhost/dashboard error

    in Windows 10 Network and Sharing
    localhost/dashboard error: Hello If I am in IE11 and type in the following in my address bar: localhost/dashboard and get 'Can't find the page', what does that mean, please? There is nothing wrong with my Internet connection - hence, I can post this message. I have run hitman antimalware,...
  6. How to configure Defender for Localhost

    in AntiVirus, Firewalls and System Security
    How to configure Defender for Localhost: I am a software developer and spend a lot of time running software on my computer's localhost (installed with Xampp). Unfortunately this localhost is horribly slow - even on a fast computer and I suspect MS Defender to be the main culprit (I use the default settings). So...
  7. localhost

    in Windows 10 Network and Sharing
    localhost: I am still not able to configure localhost in windows 10. I am web developer
  8. This site can’t be reached - localhost refused to connect.

    in Windows 10 Network and Sharing
    This site can’t be reached - localhost refused to connect.: I'm trying to connect to my Cyber Power UPS web based management software (PPBE) but keep receiving: This site can’t be reached localhost refused to connect. Search Google for localhost 3052 agent ERR_CONNECTION_REFUSED I get the same error in Chrome, Edge and Firefox. I...
  9. Localhost not working in windows 10

    in Windows 10 Software and Apps
    Localhost not working in windows 10: I have used Dreamweavin all its versions except CC and apache server in all versions of windows for the last 18 years. In windows 10, when I attempt to access localhost, all I get is a blank page. In every other version of windows, typing http://localhost/ brings up a screen...
  10. Loopback/localhost acces in apps

    in Windows 10 Software and Apps
    Loopback/localhost acces in apps: This is aimed at Win 8, but should be the same for 10 As some of us have found out, modern apps such as Edge are not allowed to send network traffic to the local host, so things like media servers and routers do not work I have just been trying out some media server...