Virtual hosts doesn't work when internet is offline

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

Virtual hosts doesn't work when internet is offline

Postby Darek » 03. October 2011 19:28

What I'm using:

XAMPP ver. 1.6.7
Windowx Vista Home


My configuration:

I have configured windows hosts like this:

Code: Select all
127.0.0.1 localhost
127.0.0.1 test.local


and xampp (apache) virtual hosts like this:

Code: Select all
<VirtualHost *:80>
  ServerName test.local
  DocumentRoot "D:\xampp\htdocs\test"

  <Directory "D:\xampp\htdocs\test">
    AllowOverride All
  </Directory>
</VirtualHost>


The problem is:

When I have internet connection I can access http://localhost/phpmyadmin AND http://test.local
When I'm offline, I can only access http://localhost/phpmyadmin BUT NOT http://test.local

How do I solve this, and why virtual hosts require internet connection to work?
Last edited by Darek on 03. October 2011 20:44, edited 1 time in total.
Darek
 
Posts: 4
Joined: 03. October 2011 19:19

Re: Virtual hosts doesn't work when internet is offline

Postby WilliL » 03. October 2011 19:52

is in the beginning of your "httpd-vhosts.conf" the following command?
Code: Select all
NameVirtualHost 127.0.0.1:80


If not please have a look to http://httpd.apache.org/docs/2.2/en/vhosts/
Willi
WilliL
 
Posts: 660
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: Virtual hosts doesn't work when internet is offline

Postby Darek » 03. October 2011 20:07

When I added
Code: Select all
NameVirtualHost 127.0.0.1:80

I can't access localhost at all

Code: Select all
NameVirtualHost *:80

This code above works, but it seems that this line doesn't change anything from my previous configuration.
Darek
 
Posts: 4
Joined: 03. October 2011 19:19

Re: Virtual hosts doesn't work when internet is offline

Postby Sharley » 03. October 2011 20:32

We require your XAMPP version and your Windows Version to provide the correct version support.
viewtopic.php?f=16&t=48331
viewtopic.php?f=16&t=32670

Thanks.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Virtual hosts doesn't work when internet is offline

Postby Darek » 03. October 2011 20:46

Sorry for that, I already updated my first post providing XAMPP and Windows version.

Also I noticed interesting thing:

1. With internet connection I can ping test.local
2. Without internet connection, when I try to ping test.local I get this message: "Ping request could not find host test.local. Please check the name and try again."
Darek
 
Posts: 4
Joined: 03. October 2011 19:19

Re: Virtual hosts doesn't work when internet is offline

Postby Sharley » 03. October 2011 21:00

I see a very old XAMPP version is there any reason not to use the latest version?

Are you logged into Vista as an Administrator?

Try this configuration in the httpd-vhosts.conf file in the extra folder as it seems you have not included all required entries - you can copy and paste it but first make a backup copy of the original:
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName test.local
DocumentRoot "D:/xampp/htdocs/test"
<Directory "D:/xampp/htdocs/test" >
Options Indexes +FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Save the file and restart Apache.

It has been mentioned here that nesting a vhost is not recommended ie. using the htdocs folder to add another folder that is a VirtualHosts but it should work if all the configurations are correct.

A virtual host can be setup to access any folder on your PC.

Good luck. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Virtual hosts doesn't work when internet is offline

Postby Darek » 03. October 2011 21:38

Sharley wrote:I see a very old XAMPP version is there any reason not to use the latest version?

The only reason is that our client's hosting have old version of PHP and MySQL installed. We found that there's few differences between old and new version, and we needed to test the whole system on our computers. That's why we choose old XAMPP version.

Sharley wrote:Are you logged into Vista as an Administrator?

Of course.

Sharley wrote:Try this configuration in the httpd-vhosts.conf(...)

I tried it, but the problem is still there. Now I think it may not be apache problem, but something with Windows itself.


Solution: As I write this post, I found solution to my problem. It was in fact Windows problem. It appears that if "DNS Client" service is turned off, Windows doesn't use hosts file when computer is offline. Maybe this will help someone in future, as I was searching for solution to this problem, found few similar questions, but not a single solution.
Darek
 
Posts: 4
Joined: 03. October 2011 19:19

Re: Virtual hosts doesn't work when internet is offline

Postby Sharley » 03. October 2011 21:55

Thanks for the feed back. 8)

Best wishes. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Virtual hosts doesn't work when internet is offline

Postby angelace » 05. October 2011 16:12

Solution: As I write this post, I found solution to my problem. It was in fact Windows problem. It appears that if "DNS Client" service is turned off, Windows doesn't use hosts file when computer is offline. Maybe this will help someone in future, as I was searching for solution to this problem, found few similar questions, but not a single solution.


... It did help someone else (today) . Thanks for the timely post... back to the grind - Angela
angelace
 
Posts: 1
Joined: 05. October 2011 16:03


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 110 guests