【问题标题】:Sensitive URLs accessible [duplicate]可访问的敏感 URL [重复]
【发布时间】:2019-08-31 06:11:05
【问题描述】:

当我用 .htaccess 在浏览器上点击 url 时,我可以看到 htaccess 的代码。应该是禁止访问!或无法访问。我如何限制 htaccess,因为没有人可以访问它。

domainname/.htaccess 它显示了 htaccess 的代码。

Options +FollowSymLinks
RewriteEngine on

# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

php_value memory_limit 256M enter image description here

【问题讨论】:

  • 这是一个问题吗?
  • 是的。我正面临这个错误。网址可访问。
  • 举一个不应该访问的url示例?
  • 您的问题是什么?你有什么错误吗?

标签: php


【解决方案1】:

Htaccess RedirectMatch 可用于隐藏/保护某些文件扩展名:

Options +FollowSymLinks
RewriteEngine on

RedirectMatch 403 \.(htaccess|htpasswd|ini|log|sh|inc|bak|bkp|sql)$

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

结果:

example.com/.htaccess -> 403
example.com/test -> 200 index.php
example.com/test.php -> 200 index.php

阅读以下问题:How to hide certain file type using apache .htaccess?

【讨论】:

    【解决方案2】:

    检查您的 apache.config 文件。

    <Files ".ht*">
    Require all denied
    </Files>
    

    添加此代码。它将限制访问 .htaccess 文件

    【讨论】:

      猜你喜欢
      • 2020-03-30
      • 1970-01-01
      • 2013-11-15
      • 2021-03-09
      • 2011-06-02
      • 1970-01-01
      • 2014-12-13
      • 2022-01-17
      • 1970-01-01
      相关资源
      最近更新 更多