从外部 LAN 作为虚拟主机访问本地虚拟主机,例如 http://sitename 而不是 http://systemname/sitename

发布于 2024-09-30 05:48:28 字数 1111 浏览 5 评论 0 原文

我正在开发一个网站,该网站由两个人管理。一个是我,另一个是设计者,通过局域网从不同的机器访问。

配置:php、apache、windows xp、mysql。

文档根目录:d:\www\xampp\htdocs。所有项目都在此作为子文件夹。

我已经设置了虚拟主机,这样我就不会访问所有项目 http://localhost/foldername 但就像 < a href="http://文件夹名称" rel="noreferrer">http://文件夹名称。

但对于其他系统中的设计者来说,他必须访问 http://computername/foldername

例如让我在项目工资单中工作。我将访问它作为 http://payroll 但我的设计师将访问它作为 http://computername/payroll

我想做的是我希望设计师以我访问的方式进行访问。即 http://payroll

这样,在设计器系统中,当服务器名称是工资单时,我希望将其定向到我的计算机,然后定向到项目文件夹。因此,如果他提供 http://payroll 那么我系统中的应用程序应该为他运行。

我已经在设计器系统中设置了主机文件以指向我的机器。所以这项工作已经完成,当他给工资单时,我的 http://localhost 就会出现。

我应该怎么做才能让设计师从他的系统中访问我的项目,例如 http://payroll

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, windows 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生生不灭 2024-10-07 05:48:28

设计者必须将您的 IP 地址和每个sitename 添加到他的 hosts 文件中 因为没有它,他的浏览器将不知道在哪里寻找该网站。它可能看起来像这样:

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

如果您的 VirtualHosts 没有绑定到特定的 IP 地址,这可能就足够了。这是行不通的: 应该

NameVirtualHost 127.0.0.1:80

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

是这样:

NameVirtualHost *:80

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

这样,每当 apache 看到主机名 sitename 的请求时,它就会为名为 sitename 的站点提供服务,并且无论它是否到达都没关系是否来自同一台计算机。

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.

帅气称霸 2024-10-07 05:48:28

他可以将其放入 \windows\system32\drivers\etc\hosts 文件中:


1.2.3.4 payroll

其中 1.2.3.4 应替换为系统的 IP 号。

Apache site-enabled\000-default 文件应以以下内容开头:


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

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文