Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.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
.htaccess以保护我的网站的文件夹_.htaccess - Fatal编程技术网

.htaccess以保护我的网站的文件夹

.htaccess以保护我的网站的文件夹,.htaccess,.htaccess,例如,当一些人试图访问时,我想给出一个301错误 或者其他文件夹。如果用户试图访问某些文件夹,您可能希望将其重定向到主页?一种方法是根据试图访问不存在的文件或目录的用户进行重定向。为了使其工作,您的文件夹中不能有DocumentIndex(index.html、index、html、index.php等)中的任何内容。这将放在一个.htaccess文件中,该文件必须放在每个要“保护”的文件夹中 301不是一个错误,它是一个永久重定向。其他文件夹是什么?请注意,如果使用永久重定向“保护”文件夹,

例如,当一些人试图访问时,我想给出一个301错误


或者其他文件夹。

如果用户试图访问某些文件夹,您可能希望将其重定向到主页?一种方法是根据试图访问不存在的文件或目录的用户进行重定向。为了使其工作,您的文件夹中不能有DocumentIndex(index.html、index、html、index.php等)中的任何内容。这将放在一个.htaccess文件中,该文件必须放在每个要“保护”的文件夹中


301不是一个错误,它是一个永久重定向。其他文件夹是什么?请注意,如果使用永久重定向“保护”文件夹,则所有内容都将不可用。在您的示例中,如果您希望从
/images
目录提供站点的图像文件,则不会显示任何图像文件。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ / [R]