因此,我想知道你们的专业人士如何通过不允许用户手动将url输入到某个文件夹(如website.com/images/ )并查看目录列表来保护您的网站。我一直使用的方法是放置一个index.php文件并使用这段代码,这将用户带回主主页。但我觉得可能有更简单的方法来做到这一点。可能是服务器端?
<?php
ob_start();
/* This will give an error. Note the output
* above, which is before the header() call */
header('Location: ../index.php');
exit;
?>发布于 2013-12-04 04:29:36
使用htaccess防止直接访问
创建.htaccess文件,添加此Options -Indexes行。将其添加到项目根路径中。
这些链接可能会帮助您1. deny directory listing with htaccess 2. http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-prevent-htaccess-directory-listing/
https://stackoverflow.com/questions/20366827
复制相似问题