【问题标题】:Restrict User For Folder Access in php在php中限制用户访问文件夹
【发布时间】:2016-03-25 15:36:57
【问题描述】:

我是 php 新手,我想限制用户访问文件夹,用户无法访问我的图像文件夹,我在该图像文件夹中有一个拇指文件夹,我该怎么办。

示例:- 我有一个文件夹 _cat_img,我还有一个文件夹,名称为 thumb。 我想限制两个文件夹的用户 我尝试使用带有 .htaccess 的代码,但它不起作用。 我在 htaccess 中使用它

    **Deny from All**

但它是限制所有文件夹我应该做些什么来限制用户访问特定文件夹的任何人都可以帮助我

【问题讨论】:

    标签: php


    【解决方案1】:

    使用Directory apache 指令指定特定目录。然后在其中给出访问指令(允许或拒绝)。

    <Directory "fullpath/_cat_img">
     Order Deny,allow
     Deny from all
    </Directory>
    
    
    <Directory "full_path/thumb">
     Order Deny,allow
     Deny from all
    </Directory>
    

    编辑

    要激活 .htaccess,请编辑您的 apache conf 并在您网站的虚拟主机部分添加这些。

    <Directory documnet_root>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
    

    重启apache。

    【讨论】:

    • 不工作,因为我有一个文件夹“aanshi”,但在 htaccess 中使用此代码,但现在我无法打开我的 aanshi 文件夹
    • 这就是我所说的完整路径。
    猜你喜欢
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-07
    • 1970-01-01
    • 2011-04-16
    • 2012-07-14
    相关资源
    最近更新 更多