通过IP地址范围,以文件的htaccess的访问 [英] htaccess access to file by ip range

查看:174
本文介绍了通过IP地址范围,以文件的htaccess的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何只允许访问文件的用户使用的IP它是在一个范围内的IP地址?

How to allow access to file only to users with ip which are in a range of ip addresses?

例如文件admin.php文件。范围从0.0.0.0至1.2.3.4。

For example file admin.php. and range from 0.0.0.0 to 1.2.3.4.

我需要配置不目录只能访问一个文件。

I need configure access to only ONE file not to directory.

推荐答案

只需添加一个 FilesMatch 文件指令将其限制在一个特定的脚本。

Just add a FilesMatch or Files directive to limit it to a specific script.

下面会阻止存取权限给所有脚本admin.php文件结尾的:

The following would block acces to all scripts ending in "admin.php" :

<FilesMatch "admin\.php$">
    Order deny,allow
    Deny from all
    Allow from 10.0.0.0/24
</FilesMatch>

下面只会阻止admin.php的:

The following would ONLY block admin.php :

<Files "admin.php">
    Order deny,allow
    Deny from all
    Allow from 10.0.0.0/24
</Files>

有关详细信息,请参考 apache的文档配置部分的。

For more information refer to the apache docs on Configuration Sections.

这篇关于通过IP地址范围,以文件的htaccess的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆