Wamp 2.5 local host doesn't work after I have

2019-09-03 17:00发布

问题:

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>