在我设置虚拟主机后,Wamp 2.5本地主机无法工作我得到403禁止错误

时间:2015-04-09 09:56:27

标签: apache localhost wamp ip-address virtualhost

我现在设置了虚拟主机,当我键入localhost它不起作用我想现在我必须为自己的本地主机创建一个虚拟主机并且它工作但现在当我键入我的外部IP时它确实不工作它说403禁止所以我如何解决这个问题我必须为我的外部IP做一个虚拟主机,它是否适用于每个人或只是我的电脑,例如,如果我给一个朋友,他键入我的外部IP将它工作?

1 个答案:

答案 0 :(得分:0)

创建虚拟主机时,Apache忽略了httpd.conf中定义的主机,即localhost。所以你必须为localhost创建一个vhost。

为安全起见,它应该是第一个定义的vhost,好像有人只是尝试你的ip地址,Apache将默认为第一个vhost,并且将使用仅本地访问进行定义,并且它们将获得错误,说你不被允许进入。

根据您的其他问题,如果用户实际输入了有效的.tk域名,则应该只允许访问您的xxx.tk域名,如果他们只使用您的wan ip地址则禁止访问。< / p>

# 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>
    ServerAdmin webmaster@homemail.net
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "c:/wamp/www">
        AllowOverride All
        <IfDefine APACHE24>
            Require local
        </IfDefine>
        <IfDefine !APACHE24>
            Order Deny,Allow
            Deny from all
            Allow from 127.0.0.0 localhost ::1 
        </IfDefine>
    </Directory>
</VirtualHost>