【问题标题】:standard method for redirect on manual input url手动输入网址重定向的标准方法
【发布时间】:2013-12-20 10:27:06
【问题描述】:

所以我想知道你们的专业人员如何通过不允许用户手动输入某个文件夹(例如 website.com/images/)的 URL 并查看目录列表来保护您的网站。我一直在使用的方法是放置一个 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;
?>

【问题讨论】:

  • 对不起,如果这是另一个问题的欺骗,我真的不知道我会搜索什么来回答这个问题

标签: php security url


【解决方案1】:

使用 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/

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多