wampserver 主页仅从本地主机可见 [英] wampserver homepage only visible from localhost

查看:32
本文介绍了wampserver 主页仅从本地主机可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Recently I used WAMP server to set up a server environment in a Windows machine. Everything works great, but I have a little problem: everyone can access the wampserver homepage, therefore they can see other webpages hosted in the same server, the server file system, etc.

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

The URLs of the webpage have the following format: hostname/project1, hostname/project2... The main problem is that, anyone can see all the projects that are hosted by going to the direction of the hostname because this will lead to the wampserver homepage, and I would prefer that this homepage could be accessed only in the localhost of the windows host. Is there any way to do that? I'm guessing that I will need to modify some parameters in configuration files, but I have no idea wich ones...

推荐答案

如果您打算阻止从外部访问此计算机上托管的所有站点,您可以在位于 < 的主 apache 配置文件中执行此操作.安装驱动器>/wamp/bin/apache/Apache<版本号>/conf/httpd.conf..htaccess 更适用于每个站点的配置,但如果您将其放在主 www 目录中,它肯定会起作用.

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.

要禁止外部访问 www 文件夹(默认打开),找到 apache 配置文件(如上所示的路径)的部分,如下所示:

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>

并将其更改为:

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

如果您的目标不是阻止外部访问您的所有网站,那么了解有关您的设置的更多信息会有所帮助.如果您的目标只是阻止 'localhost' 页面并仍然允许访问,例如,'localhost/site1' 那么这个问题可能与 这个.

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.

正如您所指出的,我链接的问题没有很好的解决方案.假设您将公共站点设置为 webroot 子文件夹中的虚拟主机,例如:

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

然后您可以返回到您的 httpd.conf 并将其添加到您的/wamp/www/规则下方:

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>

这将允许 www 文件夹中的任何内容只能在本地访问,而 vhosts 子文件夹中的任何内容都可以在外部访问.同样,每次更改此文件时,请记住重新启动 Apache.

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.

这篇关于wampserver 主页仅从本地主机可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆