我正在尝试为通过wampserver托管的网站创建一个网址,但无论我做什么,我都无法让网址正常工作。该网站是在线的,因为我能够通过服务器IP地址进行连接。
(我还应该提一下,该网站仅在内联网上提供)
主持文件:
switchSlideEvent
vhosts.conf:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 www.socialclub.com #also tried public/private IP, still only works locally
我看过的每个指南都说这应该有用,但它只适用于本地。如果URL可以从其他计算机上运行,我需要做什么?
答案 0 :(得分:1)
好的我认为问题是您不了解HOSTS文件的用途及其范围。
HOSTS文件仅影响它所使用的单个PC。它用于在启动时为Windows DNS缓存设定种子。因此,无论您放入此文件中的任何内容都不会影响您Intranet中的任何其他PC。
有几种解决方案:
让我们假设运行WAMPServer的PC的IP地址为192.168.1.10:
您可以转到Intranet中的每台PC并对其进行更改 每台PC上的HOSTS文件
192.168.1.10 socialclub.com
人们通常认为这太麻烦了,特别是如果他们有超过5-6个PC来修改
您可以安装本地DNS服务器,也可以使用现有的DNS服务器 本地DNS服务器。然后,只要您的Intranet中的所有PC都是 使用该DNS服务器将域名添加到该DNS服务器。
人们通常认为这是一个好主意,但要实现这一目标并且不能在网络上无法访问真正的DNS服务器,这可能会非常复杂
首先将localhost指向原始的wampserver主页,但只允许从运行WAMPServer的PC进行访问。主页上的工具对于调试/诊断/等非常有用,但只允许从运行WAMPServer的PC访问locahost。
其次将<Directory></Directory>
块放在虚拟主机定义中。这允许您使每个虚拟主机安全特定于该虚拟主机。
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:\Data\Users Apps\wamp\www\socialclub"
ServerName www.socialclub.com
<Directory "E:\Data\Users Apps\wamp\www\socialclub">
AllowOverride All
Options Indexes FollowSymLinks Includes ExecCGI
# assuming your subnet equates to this range
# and you are using Apache 2.4.x
# its not necessary to allow access from all in an intranet
# in fact it might be dangerous
Require ip 192.168.1
</Directory>
</VirtualHost>