Path confusion in XAMPP when running on Edge Browser

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Re: Path confusion in XAMPP when running on Edge Browser

Postby JJ_Tagy » 20. October 2015 23:39

I assume this is because localhost may be the only loopback entry allowed in Edge. To test, I use this with my hosts file pointing all 4 to 127.0.0.1:

Code: Select all
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory "C:/xampp/htdocs">
        Require all granted
        AllowOverride All
        Options Indexes FollowSymLinks
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@test1.com
    DocumentRoot "C:/xampp/vhosts/test1"
    ServerName test1.com
    ErrorLog "logs/test1.com-error.log"
    CustomLog "logs/test1.com-access.log" common
    <Directory "C:/xampp/vhosts/test1">
        Require all granted
        AllowOverride All
        Options Indexes FollowSymLinks
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@test2.com
    DocumentRoot "C:/xampp/vhosts/test2"
    ServerName test2.com
    ErrorLog "logs/test2.com-error.log"
    CustomLog "logs/test2.com-access.log" common
    <Directory "C:/xampp/vhosts/test2">
        Require all granted
        AllowOverride All
        Options Indexes FollowSymLinks
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@test3
    DocumentRoot "C:/xampp/vhosts/test3"
    ServerName test3
    ErrorLog "logs/test3-error.log"
    CustomLog "logs/test3-access.log" common
    <Directory "C:/xampp/vhosts/test3">
        Require all granted
        AllowOverride All
        Options Indexes FollowSymLinks
    </Directory>
</VirtualHost>


The first 3 (localhost, test1.com, test2.com) work perfectly as expected. If I try "test3", the search engine takes over. If I try "http://test3/", it times out. Try for your system to see if you can get it to work with .com or .local or something.
JJ_Tagy
 
Posts: 788
Joined: 30. January 2012 13:44
XAMPP version: 5.5.15
Operating System: Windows 10 Pro x64

Re: Path confusion in XAMPP when running on Edge Browser

Postby Altrea » 21. October 2015 21:46

Totally aggree with JJ_Tagy. That is what i have tried to say in my second post in this thread here. Maybe i have not choosen the best words.

Last but not least:
Don't nest any vhost into another (like you did with localhost and your other vhosts).
If your configuration would only include independend DocumentRoots for each vhost (like in JJ_Tagys example) than you would not be so confused now that prepending localhost works (because it uses the vhost configuration of localhost and not the one you have configured for it) while using the specific ServerName does not.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Path confusion in XAMPP when running on Edge Browser

Postby TomXampp » 23. October 2015 17:53

Thank you, JJ_Tagy and Altrea for responding, now that the httpd-vhosts.conf confusion is cleared up (and again, it was my error in mistyping that info).

What I have discovered, after analyzing your responses and testing them out, is that the following settings (the addition of one extra line of code in each of the files in question) comprise the magic bullet on my systems:

In httpd-vhosts.conf:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/mysite"
    ServerName mysite
    ServerAlias mysite.dev
</VirtualHost>


In HOSTS:

Code: Select all
127.0.0.1      mysite
127.0.0.1      mysite.dev


This allows me to access mysite with "mysite" on all browsers except Edge, and "mysite.dev" on Edge.

If I understand you correctly, it is bad form to put sites into the 'htdocs' directory of XAMPP, which serves as the primary localhost. Suggesting otherwise is the XAMPP httpd-vhosts.conf file itself, which provides two examples at the top of its default form (i.e., as it is shipped):

Code: Select all
##<VirtualHost *:80>
    ##ServerAdmin webmaster@dummy-host.example.com
    ##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
    ##ServerName dummy-host.example.com
    ##ServerAlias www.dummy-host.example.com
    ##ErrorLog "logs/dummy-host.example.com-error.log"
    ##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>

##<VirtualHost *:80>
    ##ServerAdmin webmaster@dummy-host2.example.com
    ##DocumentRoot "C:/xampp/htdocs/dummy-host2.example.com"
    ##ServerName dummy-host2.example.com
    ##ErrorLog "logs/dummy-host2.example.com-error.log"
    ##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>


And there are numerous examples online of others putting their sites in subfolders of htdocs, such as what the apachefriends moderator provides in the responses to this post:
https://community.apachefriends.org/f/viewtopic.php?p=183394

However, I may have misunderstood you on this point. If not, I'll take your advise on moving the code of my various development sites out of "htdocs" and into a different folder.
TomXampp
 
Posts: 59
Joined: 12. March 2015 03:58
Operating System: Windows 8.1

Re: Path confusion in XAMPP when running on Edge Browser

Postby Altrea » 24. October 2015 00:10

TomXampp wrote:If I understand you correctly, it is bad form to put sites into the 'htdocs' directory of XAMPP, which serves as the primary localhost.

No. Technically you can put your files whereever you want and yes it is technically possible to nest virtual hosts too.
But technically possible does not mean it is wise or recommend.

There is only one benefit from placing project files somewhere inside htdocs: You can omit the <Directory> Block to grant access permissions to that ressources because there is already access granted for htdocs and this access rules are getting inherited.

All in all confuguration of vhosts is very much a matter of personal likes and dislikes if doing with correct syntax. But if you do something wrong then debugging (e.g. nested vhosts) can be a mess.

I have a personal template i use configurating my vhosts every time, which is looking like the following:
Code: Select all
##localhost##
<VirtualHost *:80>
    DocumentRoot "C:/vhosts/localhost/htdocs"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory "C:/vhosts/localhost/htdocs">
        Options Indexes FollowSymLinks Includes ExecCGI
        Require all granted
        AllowOverride All
    </Directory>
</VirtualHost>
##localhost##

##example.com##
<VirtualHost *:80>
    DocumentRoot "C:/vhosts/example.com/htdocs"
    ServerName example.com
    ServerAlias www.example.com
    ErrorLog "logs/example.com-error.log"
    CustomLog "logs/example.com-access.log" common
    <Directory "C:/vhosts/example.com/htdocs">
        Options Indexes FollowSymLinks Includes ExecCGI
        Require all granted
        AllowOverride All
    </Directory>
</VirtualHost>
##example.com##

##example.net##
<VirtualHost *:80>
    DocumentRoot "C:/vhosts/example.net/htdocs"
    ServerName example.net
    ServerAlias www.example.net
    ErrorLog "logs/example.net-error.log"
    CustomLog "logs/example.net-access.log" common
    <Directory "C:/vhosts/example.net/htdocs">
        Options Indexes FollowSymLinks Includes ExecCGI
        Require all granted
        AllowOverride All
    </Directory>
</VirtualHost>
##example.net##


As you can see that the domain name is used nearly everywhere in its specific configuration, like in the name of the DocumentRoot, the name of the log files, etc.
And each vhost does have at least one folder above it's own dedicated htdocs for scripts and files that should not be requestable.
I would never nest vhost DocumentRoot folders. In my opinion it is more clear to have a <Directory> Block configurated for each vhost.

btw: my localhost vhost is the default vhost which gets used if a domain is used that is not specified. The default vhost is the vhost placed on the very top of your vhost configuration. That is another reason for not nesting vhosts and place the vhost with the shortest path at the top.

Do whatever you want and what makes the most sense for you, but keep in mind that it can have negative sideeffects.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Previous

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 126 guests