Steven
Steven

Reputation: 19425

Forbidden: You don't have permission to access /

I've looked as so many examples here, but I still can't access my WAMP server from my other computer. I have no problem from the computer where WAMP is installed.

I notice that it says You don't have permission to access / - why / ?

// httpd.conf

<Directory "D:/wamp/www/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from ::1
    Allow from 192.168.0.1 // <- typo
    Allow from 192.168.1.148
</Directory>

//httpd.vhosts.conf

<VirtualHost 192.168.1.119>
    DocumentRoot D:/wamp/www/mysite/
    ServerName mysite.com
    ServerAlias mysite.com
</VirtualHost>

// Host file

192.168.1.119 localhost
192.168.1.119 mysite.com

Upvotes: 1

Views: 3431

Answers (1)

RiggsFolly
RiggsFolly

Reputation: 94652

Try these changes

First this controls access to your WAMPServer homepage, add all the possible local address to the allow list.

You seem to have 2 subnets in your list, is that a typo? I am assuming so.

Also if you use just the first 3 quartiles of the ip address it will allow from any ip on that subnet.

// httpd.conf

<Directory "D:/wamp/www/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from ::1 127.0.0.1 localhost
    Allow from 192.168.1
</Directory>

You dont mention any port number on your VHOST definition and there is no need to use a specific ip address.

Also it is a good idea to add a localhost VHOST, and to put the access restrictions i.e. the <Directory...> block inside each individual VHOST definition. Then you can modify the access privilages on each VHOST specifically.

Also the syntax for the access rights chnaged in Apache 2.4.x so I have coded the access rights section using the parameter that was added in WAMPServer2.5 releases, but it should work as it is even of you are still on an older WAMPServer version i.e. 2.4 or 2.2

// extras/httpd-vhost.conf

# 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 "D:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "D:/wamp/www">
        AllowOverride All
        <IfDefine APACHE24>
            Require local
            Require ip 192.168.1
        </IfDefine>
        <IfDefine !APACHE24>
            Order Deny,Allow
            Deny from all
            Allow from 127.0.0.0/8 localhost ::1 192.168.1
        </IfDefine>
    </Directory>
</VirtualHost>



<VirtualHost *:80>
    DocumentRoot "D:/wamp/www/mysite"
    ServerName mysite.com
    ServerAlias www.mysite.com
    <Directory  "D:/wamp/www">
        AllowOverride All
        <IfDefine APACHE24>
            Require local
            Require ip 192.168.1
        </IfDefine>
        <IfDefine !APACHE24>
            Order Deny,Allow
            Deny from all
            Allow from 127.0.0.0/8 localhost ::1 192.168.1
        </IfDefine>
    </Directory>
</VirtualHost>

Upvotes: 1

Related Questions