3

最近我在一台Windows机器上使用WAMP服务器搭建了一个服务器环境。一切都很好,但我有一个小问题:每个人都可以访问 wampserver 主页,因此他们可以看到托管在同一服务器上的其他网页、服务器文件系统等

网页的 URL 格式如下:hostname/project1hostname/project2...主要问题是,任何人都可以通过转到主机名的方向看到所有托管的项目,因为这将导致 wampserver 主页,我更喜欢这个主页只能在 windows 主机的 localhost 中访问。有没有办法做到这一点?我猜我需要修改配置文件中的一些参数,但我不知道哪些...

4

4 回答 4

5

If you intend to block access to all sites hosted on this computer from outside access, you can do this in your main apache configuration file at <installation drive>/wamp/bin/apache/Apache<version number>/conf/httpd.conf. .htaccess is more for per-site configurations, though it will certainly work if you put it in the main www directory.

To disallow outside access to the www folder (open by default) find the part of the apache configuration file (path shown above) that looks like:

<Directory "<installation drive>/wamp/www">
    # There will be comments here and some options like FollowSymLinks and AllowOverride
    Order Allow,Deny
    Allow from all
</Directory>

And change it to:

<Directory "<installation drive>/wamp/www">
    # There will be comments here and some options like FollowSymLinks and AllowOverride
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>

If your goal is not to block outside access to all of your sites, it would help to know more about your set up. And if your goal is only to block the 'localhost' page and still allow access to, say, 'localhost/site1' then this question may be a duplicate of this.

Edit: As you point out, there is not a good resolution for the question I linked. Assuming you have your public sites set up as virtual hosts in a sub folder of the webroot like:

|-wamp_root
  |-www
    |-vhosts
      |-public_site_1
      |-public_site_2

Then you can go back into your httpd.conf and add this below your /wamp/www/ rule:

<Directory "<installation drive>/wamp/www/vhosts/">
    # There will be comments here and some options like FollowSymLinks and AllowOverride
    Order Allow,Deny
    Allow from all
</Directory>

This will allow anything in the www folder to be accessed only locally, and anything in the vhosts sub folder to be accessible outside. Again, remember to restart Apache whenever you change this file.

于 2013-02-06T16:42:59.080 回答
1

应该可以使用 windows 防火墙阻止其他用户。您也可以使用像这样的 .htaccess 文件:

Order deny,allow
Deny from all
Allow from 127.0.0.1

您必须确保在 apache 配置AllowOverride中设置为All,并且 .htaccess 也将应用于所有子目录,否则您的项目仍然可用。

于 2013-02-06T11:18:58.110 回答
0

看来(在我自己有点头疼之后),这个问题的答案很简单。

在 Windows 任务栏中,左键单击 WAMP 图标,然后单击“脱机”。

它似乎没有让整个网络服务器“离线”,只是根主页?并且您在 httpd.conf 文件中配置为可从外部访问的任何内容仍然存在,它们仍然可以访问。

注意:默认的 VHOST 仍然可以访问,例如 PHPINFO 和 PHPMYADMIN!

于 2019-08-12T01:21:16.533 回答
-1

这并不难。

  1. 用notepad++编辑索引文件
  2. 找到 &projectContents 行
  3. 从 &projectContents 更改为 &project---Contents

然后项目标题消失。

于 2016-05-15T18:20:37.863 回答