开发者

accessing a local virtual host from outside LAN as virtual host like http://sitename instead of http://systemname/sitename

I am developing a site and that that is managed by two. one is me and the other is the designer accessing from different machines across LAN.

Conf: php, apache, win开发者_运维知识库dows xp, mysql.

Document root: d:\www\xampp\htdocs. all the projects are under this as subfolders.

I have set up virtual host so that i will not access all the projects as http://localhost/foldername but just as http://foldername.

But for the designer who is in the other system he has to access like http://computername/foldername

For example let me be working in a project payroll. i will access that as http://payroll but my designer will access that as http://computername/payroll.

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

so that in the designer system when the server name is payroll i want it to be directed to my machine and then to the project folder. so if he gives http://payroll then the application in my system should run for him.

i have setup the hosts file in the designer system to point to my machine. so this work is done and when he gives payroll my http://localhost is appearing.

what should i do so the designer can access my project like http://payroll form his system?


The designer has to add your IP address with each sitename to his hosts file as without it his browser won't know where to look for the site. It could look like this:

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

This might be enough if your VirtualHosts are not bound 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>

This way apache will serve the site called sitename whenever it sees a request with the hostname sitename and it won't matter if it came from the same computer or not.


He can put into his \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 Apache sites-enabled\000-default file 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜