Wamp是绿色和在线但仍然是403错误

时间:2015-09-13 14:59:49

标签: apache wamp wampserver

C:\wamp\bin\apache\apache2.4.9:

<VirtualHost *:80>
    DocumentRoot C:\wamp\wwww\sk\public
    ServerName sk.localhost
    SetEnv APPLICATION_ENV "development"

  <Directory "C:\wamp\wwww\sk\public">
    Options Indexes FollowSymLinks MultiViews
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
    Require local
    Allow from localhost ::1 127.0.0.1
  </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot C:\wamp\wwww\sk\public
    ServerName sk.localhost
    SetEnv APPLICATION_ENV "development"
  <Directory "C:\wamp\wwww\sk\public">
    Options Indexes FollowSymLinks MultiViews
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
    Require local
    Allow from localhost ::1 127.0.0.1
  </Directory>
</VirtualHost>

主持人文件:

    # localhost name resolution is handled within DNS itself.
    #   127.0.0.1       localhost
    #   ::1             localhost

127.0.0.1       localhost
127.0.0.1       sk.localhost

当我尝试访问localhostsk.localhost时,它会给我403 error(Wamp是绿色和在线。任何人都可以帮忙吗?我不知道我在这里做错了什么我尝试了几种来自互联网的方法但没有运气。非常感谢任何帮助。最好的问候,波格丹。

PHPMyadmin正在运作。

1 个答案:

答案 0 :(得分:0)

这可能是因为您使用了两种不同版本的访问安全语法,而Apache却变得混乱。

如下所示更改虚拟主机定义,仅使用Apache 2.4语法,而不是Apache 2.2语法。

此外,您还应该为localhost创建一个VH,就像实现虚拟主机时一样,Apache会忽略httpd.conf文件中localhost的定义。

# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC 
# 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 C:\wamp\wwww\sk\public
    ServerName sk.localhost
    SetEnv APPLICATION_ENV "development"

  <Directory "C:\wamp\wwww\sk\public">
    Options Indexes FollowSymLinks MultiViews
    DirectoryIndex index.php
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot C:\wamp\wwww\sk\public
    ServerName sk.localhost
    SetEnv APPLICATION_ENV "development"
  <Directory "C:\wamp\wwww\sk\public">
    Options Indexes FollowSymLinks MultiViews
    DirectoryIndex index.php
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

如果客户端位于运行WampServer(Apache)的PC上,Require local告诉Apache只允许访问VH域。

如果您确实希望允许通过本地网络上的另一台PC进行访问,则可以向您要访问的域中添加这样的行

Require local
Require ip 192.168.1

或者,如果您想允许从某个地方进行访问,请使用

替换这些行
Require all granted

警告 除非您真的知道自己在做什么,否则不要允许访问Universe。

PS WAMPserver在线/离线功能仅控制访问权限,并不代表APache正在运行。此外,一旦您实施虚拟主机,它就不再具有任何相关性,并且应该设置为OFFLINE,因为现在每个虚拟主机中都存在访问控制。