Using Virtual Hosts to connect from another computer

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

Using Virtual Hosts to connect from another computer

Postby JosephDuffy » 01. June 2012 10:31

Hi,
I'm trying to get my development environment a little easier to use. I currently connect to my home server that is running XAMPP via its name, "server". This takes me to the default XAMPP page.
I also have a website set up on this, lets call it "website2". To access this website, I can remotely use "server/website2", or on the server using "localhost/website2".
I have successfully setup Virtual Hosts so that on the server I can access the website via "website2.localhost". Here is my vhosts file.

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>

   DocumentRoot "c:/xampp/htdocs"

   ServerName localhost

</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "c:/xampp/htdocs/website2"

   ServerName website2.localhost

</VirtualHost>

I also have my hosts file setup with "127.0.0.1 website2. localhost".
However, I would like to be able to access the website via "website2.server", but that is not working. I have tried editing the hosts file on my computer with "192.*.*.* website2.server" (obviously replacing the * with the actual IP), but that has not helped. Ideally, I would be able to access the website via something like "website2.192.*.*.*" across the network, so I can test my websites on other devices where editing a hosts file would be impossible (an iPhone, for example).
I'm not sure if this is possible, but I thought I would ask (:
JosephDuffy
 
Posts: 3
Joined: 01. February 2012 18:40
Operating System: WHS 2011

Re: Using Virtual Hosts to connect from another computer

Postby Altrea » 01. June 2012 12:25

Hi JosephDuffy,

If you want to use a (simulated) DomainName from one computer to another, you shouldn't use the word "localhost" in it. localhost is a special identifier for the very local computer you are acting from at the moment.

To make the Domain working, there are two things that have to be true:
1st) the server where XAMPP is working on must have a valid VHost entry for that domain
2nd) the client from where the Browser sends the request must have an entry in it's local Windows HOSTS file containing the domain name and the IP of your server.

best wishes,
Altrea
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: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Using Virtual Hosts to connect from another computer

Postby JosephDuffy » 01. June 2012 20:53

Altrea wrote:Hi JosephDuffy,

If you want to use a (simulated) DomainName from one computer to another, you shouldn't use the word "localhost" in it. localhost is a special identifier for the very local computer you are acting from at the moment.

To make the Domain working, there are two things that have to be true:
1st) the server where XAMPP is working on must have a valid VHost entry for that domain
2nd) the client from where the Browser sends the request must have an entry in it's local Windows HOSTS file containing the domain name and the IP of your server.

best wishes,
Altrea

Thank you!
I have a changed the vhost and hosts file on the server to website2.server, and I also changed the hosts file on the computer I will access it from.
This works correctly on computers that I can edit the hosts file on, but do you any idea of how to get it to work on other computers (e.g. iPhones)?
JosephDuffy
 
Posts: 3
Joined: 01. February 2012 18:40
Operating System: WHS 2011

Re: Using Virtual Hosts to connect from another computer

Postby Altrea » 01. June 2012 21:42

JosephDuffy wrote:do you any idea of how to get it to work on other computers (e.g. iPhones)?

Are the computers / IPhones part of a local network (LAN or VPN) or are they part of a public network (internet)?
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: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 57 guests