使用.htaccess或其他方法阻止对子文件夹的直接访问

使用.htaccess或其他方法阻止对子文件夹的直接访问,.htaccess,web-folders,.htaccess,Web Folders,对不起,我的英语不好:) 我有个问题 如何使用错误页面阻止或重定向试图访问网站子文件夹的用户?我不需要受密码保护的文件夹,只需要为所有子文件夹显示一个错误 例如: www.mysite.com/folder-此文件夹内容对用户不可见这是一个不编辑.htaccess文件的简单解决方案 在文件夹中创建一个新的index.html或index.php文件,并将这些行写在正文中 在PHP中: <?php header("Location:../index.php");

对不起,我的英语不好:)

我有个问题

如何使用错误页面阻止或重定向试图访问网站子文件夹的用户?我不需要受密码保护的文件夹,只需要为所有子文件夹显示一个错误

例如:


www.mysite.com/folder-此文件夹内容对用户不可见

这是一个不编辑.htaccess文件的简单解决方案

在文件夹中创建一个新的index.html或index.php文件,并将这些行写在正文中

在PHP中:

    <?php    
      header("Location:../index.php");
    ?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="1;url=http://www.yourDomainName.com">
    <script language="javascript">
        window.location.href = "http://youDomainName.com"
    </script>
    <title>Page Redirection</title>
</head>
<body>
    If you are not redirected automatically, follow the <a href='http://www.yourDomainName.lk'>link to Your domain name home page</a>
</body>
</html>

在HTML中:

    <?php    
      header("Location:../index.php");
    ?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="1;url=http://www.yourDomainName.com">
    <script language="javascript">
        window.location.href = "http://youDomainName.com"
    </script>
    <title>Page Redirection</title>
</head>
<body>
    If you are not redirected automatically, follow the <a href='http://www.yourDomainName.lk'>link to Your domain name home page</a>
</body>
</html>

window.location.href=”http://youDomainName.com"
页面重定向
如果没有自动重定向,请按照
这样你就可以挡了

www.yourDomain.com/img

文件夹

www.yourDomain.com/css

您希望轻松拒绝访问的文件夹和其他文件夹。我不知道黑客是否还能绕过这些文件,但这是一个简单的解决方案。试试这个,自己看看答案