Wamp 2.5 local host doesn't work after I have setup virtual hosts I get 403 forbidden error

心已入冬 提交于 2019-12-11 20:52:52

问题


I have setup virtual hosts now when I type localhost it does not work I figured that now I'll have to make a virtual host for local host it self and it worked but now when I type my external ip it does not work it says 403 forbidden so how do i fix this do I have to make a virtual host for my external ip and will it work for everyone or just my computer for example if I give to a friend and he typed my external ip will it work?


回答1:


When you create Virtual Hosts, Apache ignored the host defined in httpd.conf i.e. localhost. So you have to create a vhost for localhost as well.

For security it should be the first vhost defined, as if someone just tries your ip address, Apache will default to the first vhost and that will be defined with only local access and they will get an error saying you are not allowed in.

As per your other question, you should only be allowing access to your .tk domains if the user actually enters a valid xxx.tk domain name and disallow access if they just use your wan ip address.

# 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>


来源:https://stackoverflow.com/questions/29535316/wamp-2-5-local-host-doesnt-work-after-i-have-setup-virtual-hosts-i-get-403-forb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!