Access the local virtual host from the local network as a virtual host, such as http: // sitename instead of http: // systemname / sitename

I develop a site and manage it two. one of them is me, and the other is a designer, accessible from different computers on a local network.

Conf: php, apache, windows xp, mysql.

Document root: d: \ www \ xampp \ htdocs. all projects are under these subfolders.

I set up a virtual host so that I don't get access to all projects like http: // localhost / foldername , but just like http: // foldername .

But for a designer who is on a different system, he must get access, for example http: // computername / foldername

For example, let me work on a project payroll. I access this as http: // payroll , but my designer will access this as http: // computername / payroll .

What I want to do is that I want the constructor to access the same way I do. i.e. http: // payroll .

so in the designer’s system, when the server name is the payroll, I want it to be directed to my machine and then to the project folder. therefore, if it gives http: // payroll , then the application on my system should work for it.

I installed the hosts file on the designers system to point to my machine. therefore, this work is done, and when it gives a salary, http: // localhost appears.

What should I do, can a designer access my project, for example http: // payroll , to create my own system?

+7
apache virtualhost
source share
2 answers

The designer must add your IP address with each sitename to his host file , since without it his browser would not know where to look for the site. It might look like this:

 12.34.56.78 sitename1 12.34.56.78 sitename2 12.34.56.78 repeat.for.each.sitename ... 

This may be sufficient if your VirtualHosts are not tied to a specific IP address. This would not work:

 NameVirtualHost 127.0.0.1:80 <VirtualHost 127.0.0.1:80> ServerName sitename1 ... </VirtualHost> 

It should be:

 NameVirtualHost *:80 <VirtualHost *:80> ServerName sitename1 ... </VirtualHost> 

Thus, apache will serve the site called sitename whenever it sees a request with the host name sitename , and it does not matter if it came from the same computer or not.

+7
source

It can put the file in its \ windows \ system32 \ drivers \ etc \ hosts file:

 1.2.3.4 payroll 

Where 1.2.3.4 should be replaced with the IP number of the system.

The default file with the 0004 Apache server should start with:

 <VirtualHost *:80> # from http://www.iliveinperego.com/2008/05/automatic-vhost-with-apache/ RewriteEngine on RewriteCond %{HTTP_HOST} ^(.+)$ RewriteRule ^(.+)$ /%1$1 ... </VirtualHost> 
+1
source

All Articles