我正在努力保护我的网络服务器。我不希望人们能够执行他们不应该的文件。
我被告知我应该否认所有可以执行的白人文件。这样可行。问题是当我访问我的domain.com时,它不会执行example.com/index.php。如果我键入example.com/index.php,则可以工作。
这是我的htaccess文件
Options -Indexes
Order deny,allow
Deny from all
<Files /index.php>
Allow from all
</Files>
<Files "index.php">
Allow from all
</Files>
<Files "teacher_login.php">
Allow from all
</Files>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
您知道什么是防止人们执行脚本不应该不应该的更好的方法?
完全不要将它们放在网上。
将这些脚本在服务器上的public_html
外部,突然间没人可以访问它们!不需要像您尝试使用的.htaccess
黑客攻击。更好的是,它们仍然可以使用服务器本身 - 例如
require($_SERVER['DOCUMENT_ROOT']."/../hidden-scripts/something.php");
更好。