[英].htaccess allow from REMOTE_HOST
l'm trying to set up an .htaccess file that will restrict access to a specific file, unless the request has come from the same server. 我正在尝试设置一个.htaccess文件,该文件将限制对特定文件的访问,除非请求来自同一服务器。
Here's what l expected to work (but it doesn't seem to): 这是我期望的工作(但似乎没有):
<Files /some/secret/cron.php>
Order deny,allow
Deny from all
Allow from %{REMOTE_HOST}
</Files>
In this instance l can't just hard code in the IP address of the server, as it changes/rolls over to other servers throughout the day. 在这种情况下,我不能只是在服务器的IP地址中进行硬编码,因为它在一天内会更改/滚动到其他服务器。
You might try this 你可以试试这个
SetEnvIf Remote_Addr 127.0.0.1 Allowed=1
<Files "/some/secret/cron.php">
Order deny,allow
Deny from All
Allow from env=Allowed
</Files>
You cannot use %{REMOTE_HOST}
in Allow from
. 您不能在“ Allow from
使用%{REMOTE_HOST}
。 Use it in a mod_rewrite
rule like this: 像下面这样在mod_rewrite
规则中使用它:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !=11.22.33.44
RewriteRule cron\.php$ - [F,NC]
Replace 11.22.33.44
by your IP address. 用您的IP地址替换11.22.33.44
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.