【问题标题】:Securing a directory with htaccess in a virtual hosting在虚拟主机中使用 htaccess 保护目录
【发布时间】:2013-04-14 23:24:51
【问题描述】:

我在我的 web 根目录中使用以下 .htaccess 来限制对其文件的公共访问:

.htaccess

<Limit GET POST>
order deny,allow
deny from all
allow from 127.0.0.1
</Limit>

但问题是我的网站托管在虚拟托管环境中,所以是否有人担心有人在我使用的同一台服务器上托管他的文件可以访问这些文件(因为我们都属于 127.0 .0.1)?

【问题讨论】:

    标签: .htaccess hosting virtual


    【解决方案1】:

    您是对的,来自同一主机的某人可以访问该目录。如果你想让它安全,我建议设置一个密码。

    AuthType Basic
    AuthName "Protected Area"
    AuthUserFile /home/www/path/to/.htpasswd
    require valid-user
    

    使用 htpasswd -c .htpasswd yourusername 创建一个 .htaccess 文件或使用在线 htaccess 密码生成器之一。

    &lt;Limit GET POST&gt;

    此外,如果您不确定要限制 POST 和 GET,请不要使用类似的方法。 Apache 提供的不止这些,即 HEAD、PUT、DELETE、CONNECT 方法来发出请求。

    The purpose of the <Limit> directive is to restrict the effect of the access controls to the nominated HTTP methods.

    一定要跳过

    【讨论】:

      猜你喜欢
      • 2013-10-20
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      • 1970-01-01
      • 2014-04-04
      • 1970-01-01
      • 1970-01-01
      • 2014-11-04
      相关资源
      最近更新 更多