virtual host seem not working

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

virtual host seem not working

Postby fuzmic » 05. May 2020 04:52

Hi peers

My newly installed xampp seem to work: thus browsing https://localhost/WEB1/index.php or localhost/WEB1 will expose website kept at c://xampp\htdocs/WEB1

This is after i have made changes to 2 files and restart apache successfully

httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/WEB1"
ServerName local.WEB1
</VirtualHost>

hosts
127.0.0.1 localhost
127.0.0.1 local.WEB1


However when i try to browse localhost it ends up in localhost/dashboard/
or if i browse local.WEB1 it show local.WEB1/dashboard/

Can someone enlighten me.
fuzmic
 
Posts: 19
Joined: 03. May 2020 12:17
XAMPP version: 7.2.30
Operating System: win 10

Re: virtual host seem not working

Postby Nobbie » 05. May 2020 09:43

Clear the browser cache. Check the error log.

Finally check if your VirtualHost Configuration is correct, enter this command into a terminal:

c:/xampp/bin/httpd -S

What is the output?
Nobbie
 
Posts: 11581
Joined: 09. March 2008 13:04

Re: virtual host seem not working

Postby fuzmic » 05. May 2020 11:16

Thank you will check 2moro
fuzmic
 
Posts: 19
Joined: 03. May 2020 12:17
XAMPP version: 7.2.30
Operating System: win 10

Re: virtual host seem not working

Postby fuzmic » 06. May 2020 05:20

Ok Nobbie

clearing cache or using another browswer that has not run url before, issue remain the same.

Using c:/xampp/apache/bin/httpd -S
gives

VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhost (C:/xampp/apache/conf/extra/httpd-vhosts.conf:45)
port 80 namevhost localhost (C:/xampp/apache/conf/extra/httpd-vhosts.conf:45)
port 80 namevhost local.cye (C:/xampp/apache/conf/extra/httpd-vhosts.conf:51)
*:443 www.example.com (C:/xampp/apache/conf/extra/httpd-ssl.conf:121)
ServerRoot: "C:/xampp/apache"
Main DocumentRoot: "C:/xampp/htdocs"
Main ErrorLog: "C:/xampp/apache/logs/error.log"
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/xampp/apache/logs/" mechanism=default
Mutex ssl-stapling-refresh: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "C:/xampp/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: SRVROOT=C:/xampp/apache


Friend what is your take?
fuzmic
 
Posts: 19
Joined: 03. May 2020 12:17
XAMPP version: 7.2.30
Operating System: win 10

Re: virtual host seem not working

Postby Altrea » 06. May 2020 06:09

I don't see an active local.WEB1 vhost, just a local.cye.
Is that the vhost not working or is local.web1 really missing here?
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: 10248
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: virtual host seem not working

Postby fuzmic » 06. May 2020 06:29

Altrea forget about the WEB1, i actually created a local.cye, not local.WEB1. :)
As you can see i did create a "localhost" but it end up with localhost/dashboard
fuzmic
 
Posts: 19
Joined: 03. May 2020 12:17
XAMPP version: 7.2.30
Operating System: win 10

Re: virtual host seem not working

Postby Altrea » 06. May 2020 07:07

localhost is intended to redirect to /dashboard. There is a file /xampp/htdocs/index.php which fires a redirect.
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: 10248
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: virtual host seem not working

Postby fuzmic » 06. May 2020 07:38

Bro even i change virtual host 'local' to 'localhs.com' it still end up in /dashboard. ???
fuzmic
 
Posts: 19
Joined: 03. May 2020 12:17
XAMPP version: 7.2.30
Operating System: win 10

Re: virtual host seem not working

Postby Altrea » 06. May 2020 07:49

The very first defined vhost also acts as a default vhost for all requests not matching any other vhost.
So maybe you are thinking you are requesting a named vhost localhs.com, but in reality it never matches and uses the DocumentRoot of the first vhost!?
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: 10248
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: virtual host seem not working

Postby fuzmic » 06. May 2020 08:40

so now

C:\WINDOWS\system32>c:/xampp/apache/bin/httpd -S
VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhs.com (C:/xampp/apache/conf/extra/httpd-vhosts.conf:45)
port 80 namevhost localhs.com (C:/xampp/apache/conf/extra/httpd-vhosts.conf:45)
port 80 namevhost local.cye.com (C:/xampp/apache/conf/extra/httpd-vhosts.conf:51)
*:443 www.example.com (C:/xampp/apache/conf/extra/httpd-ssl.conf:121)
ServerRoot: "C:/xampp/apache"
Main DocumentRoot: "C:/xampp/htdocs"
Main ErrorLog: "C:/xampp/apache/logs/error.log"
Mutex ssl-stapling-refresh: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/xampp/apache/logs/" mechanism=default
PidFile: "C:/xampp/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: SRVROOT=C:/xampp/apache
fuzmic
 
Posts: 19
Joined: 03. May 2020 12:17
XAMPP version: 7.2.30
Operating System: win 10

Re: virtual host seem not working

Postby Altrea » 06. May 2020 08:45

Okay...!?
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: 10248
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: virtual host seem not working

Postby fuzmic » 06. May 2020 15:00

Guys there seem to a common outcome .. see this link
https://stackoverflow.com/questions/38538859/xampp-virtual-hosts-not-working
fuzmic
 
Posts: 19
Joined: 03. May 2020 12:17
XAMPP version: 7.2.30
Operating System: win 10

Re: virtual host seem not working

Postby Altrea » 06. May 2020 15:07

Well... I have never had any problems defining VHosts in any of the xampp versions.
The url you quoted here, especially the top rated answer, contains so many not recommended changes...

2. Add this in httpd.conf [C:\__Server\apache\conf] . though some says there are security risks with this but couldn't find a way without this
Code: Select all
<Directory />
    AllowOverride none
    Require all granted
</Directory>

This will change the default access rule, which is a high security risk.

template of this

Code: Select all
<VirtualHost *:80>
     ServerName nameInHostsFile
     DocumentRoot "pathOfTheWindowsFileLocationWhichWillBeDocumentRoot"
     SetEnv APPLICATION_ENV "development"
     <Directory "pathOfTheWindowsFileLocationWhichWillBeDocumentRoot">
         DirectoryIndex index.php
         AllowOverride All
         Order allow,deny
         Allow from all     
     </Directory>
 </VirtualHost>

Order allow,deny and Allow from all is old Apache 2.2 syntax.

3. ADD PATH variable for php [C:\xampp\php] & slao check there is no other php path in PATH variable.

XAMPP is designed to not need any changes to the Windows PATH variable. Thats XAMPP philosophy to only change anything to the system which is really neccessary.
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: 10248
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: virtual host seem not working

Postby Altrea » 06. May 2020 15:41

I have done a test environment right now.

- Downloaded a fresh install of XAMPP 7.2.30 for Windows (7-Zip version)
- Extracted it to D:\xampp7230\
- Executed the setup_xampp.bat file to update the paths in the config files
- Added this to my Windows HOSTS file
Code: Select all
127.0.0.1    localhost
127.0.0.1    local.cye

- Added this to my D:\xampp7230\apache\conf\extra\httpd-vhosts.conf
Code: Select all
<VirtualHost *:80>
   ServerName localhost
   DocumentRoot "D:/xampp7230/htdocs"
</VirtualHost>

<VirtualHost *:80>
   ServerName local.cye
   DocumentRoot "D:/xampp7230/vhost/local.cye"
   <Directory "D:/xampp7230/vhost/local.cye">
      Options Indexes FollowSymLinks Includes ExecCGI
      AllowOverride All
      Require all granted
   </Directory>
</VirtualHost>

- Created folders D:\xampp7230\vhost\ and D:\xampp7230\vhost\local.cye
- Created a file D:\xampp7230\vhost\local.cye\index.php with the following contents
Code: Select all
<h1>VirtualHost local.cye</h1>

- Started Apache
- Request http://local.cye in my Browser and get a "VirtualHost local.cye" Headline
- Request http://localhost and get redirected to http://localhost/dashboard/ and see the XAMPP Dashboard

Everything as expected.

This is my httpd -S Output
Code: Select all
# httpd -S
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server localhost (D:/xampp7230/apache/conf/extra/httpd-vhosts.conf:44)
         port 80 namevhost localhost (D:/xampp7230/apache/conf/extra/httpd-vhosts.conf:44)
         port 80 namevhost local.cye (D:/xampp7230/apache/conf/extra/httpd-vhosts.conf:49)
*:443                  www.example.com (D:/xampp7230/apache/conf/extra/httpd-ssl.conf:121)
ServerRoot: "D:/xampp7230/apache"
Main DocumentRoot: "D:/xampp7230/htdocs"
Main ErrorLog: "D:/xampp7230/apache/logs/error.log"
Mutex ssl-stapling-refresh: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="D:/xampp7230/apache/logs/" mechanism=default
PidFile: "D:/xampp7230/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: SRVROOT=D:/xampp7230/apache
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: 10248
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: virtual host seem not working

Postby fuzmic » 07. May 2020 04:50

Bro Thanks you for the huge effort.

I can only get the xampp for window as an exe file from https://www.apachefriends.org/download.html

Where is the 7-zip version?
fuzmic
 
Posts: 19
Joined: 03. May 2020 12:17
XAMPP version: 7.2.30
Operating System: win 10

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 100 guests