简体   繁体   English

使用.htaccess拒绝输入

[英]Deny entry using .htaccess

I have a page home.php where you can only access by loging in and inside this page you can download files. 我有一个主页home.php ,您只能登录才能访问,并且在该页面内您可以下载文件。 What I am trying to do is that if you put in your browser: www.domain.com/home.php/file.pdf and enter, it does not download the file. 我要尝试做的是,如果您在浏览器中输入: www.domain.com/home.php/file.pdf并输入,它不会下载文件。 I mean, that you can only download the file by clicking on the link in home.php . 我的意思是,您只能通过单击home.php的链接下载文件。

I have tried this code, but when I click the link, it sends me Error: Forbidden. 我已经尝试过此代码,但是当我单击链接时,它将向我发送错误:禁止。

SetEnvIfNoCase Referer "^https://www.domanin.com/home.php" local_ref=1
Order Allow,Deny
Allow from env=local_ref

Thank you very much for your time. 非常感谢您的宝贵时间。

You can use the following code : 您可以使用以下代码:

SetEnvIfNoCase Referer ^https?://www.domanin.com/home.php/.+\.pdf local_ref=1

Order Allow,Deny
Allow from All
Deny from env=local_ref

This will forbid the request for - https://www.domanin.com/home.php/file.pdf (referer). 这将禁止该请求- https://www.domanin.com/home.php/file.pdf (引荐)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM