Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使目录文件夹隐藏或不可访问_Php - Fatal编程技术网

Php 使目录文件夹隐藏或不可访问

Php 使目录文件夹隐藏或不可访问,php,Php,这是我的问题,我有一个index.php,它是我的登录表单。我会解释我的问题,这样就不会太复杂了 我有一个主文件夹在里面,我有一个名为templates和index.php的文件夹,这就是它的样子 主文件夹 类(文件夹) 模板(文件夹) home.php index.php 如何使templates文件夹不可访问,以便当任何用户键入www.anysite.com/mainfolder/templates时,用户看不到我的templates文件夹或用户看不到我的目录,或者用户将被重定向到我

这是我的问题,我有一个index.php,它是我的登录表单。我会解释我的问题,这样就不会太复杂了

我有一个主文件夹在里面,我有一个名为templates和index.php的文件夹,这就是它的样子

主文件夹

  • 类(文件夹)
  • 模板(文件夹)
    • home.php
  • index.php
如何使templates文件夹不可访问,以便当任何用户键入www.anysite.com/mainfolder/templates时,用户看不到我的templates文件夹或用户看不到我的目录,或者用户将被重定向到我的错误站点。

在htaccess中尝试此操作

<Files *>
 Deny from all
</Files> 

全盘否定

在包含以下内容的文件夹中创建名为
.htaccess
的文件:

deny from all

创建一个.htaccess文件并粘贴
Redirect/mainfolder/error folder/403.php

使用htaccess重定向方法设置文件/文件夹的权限您是否尝试寻找解决方案?正如@nickle所说,您可以使用htaccess进行访问。