[英]How can i deny direct access from url to all php file and some html in my server folder using htaccess?
I'm trying to hide all the php and some html file in my server folder only by direct call from url... particularly i need to hide the register.html (this file is for users registration), and other php file.. (these php files contain sensitive data for database connection). 我试图通过直接从url直接隐藏服务器文件夹中的所有php和一些html文件...特别是我需要隐藏register.html(此文件供用户注册)和其他php文件。 (这些php文件包含用于数据库连接的敏感数据)。 How can i do this??
我怎样才能做到这一点?? Thanks for any help ;)
谢谢你的帮助 ;)
You can use this for register.html
: 您可以将其用于
register.html
:
<Files "register.html">
Order Allow,Deny
Deny from all
</Files>
and in the same way for other files. 并以相同的方式处理其他文件。
Create/edit the .htaccess file in the directory where the files are located. 在文件所在的目录中创建/编辑.htaccess文件。
For denying all direct access to all files in the directory , add this: 要拒绝直接访问目录中的所有文件 ,请添加以下内容:
Deny from all
For restricting only a specific file : 仅限制特定文件 :
<Files "register.html">
Order Allow,Deny
Deny from all
</Files>
For restricting specific file types , you need to edit the .htaccess file in the webroot folder. 要限制特定的文件类型 ,您需要在webroot文件夹中编辑.htaccess文件。 This rule will deny access to all .php and .html files in myFolder and its subdirectories.:
此规则将拒绝访问myFolder及其子目录中的所有.php和.html文件:
RewriteRule ^myFolder/.*\.(php|html)$ - [F,L,NC]
More examples on denying access to file types: https://stackoverflow.com/a/20489058/6817376 有关拒绝访问文件类型的更多示例: https : //stackoverflow.com/a/20489058/6817376
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.