.htaccess 文件中的 IP 范围
我想使用此网络功能访问 IP 范围:.htaccess 文件和 RewriteCond 中的 68.241.45.0/20。像这样的事情:
RewriteCond %{REMOTE_HOST} !^68.241.45.0/20
但它似乎不起作用。
I want to get access to a IP range with this net feature: 68.241.45.0/20 in .htaccess file and in RewriteCond. Something like this:
RewriteCond %{REMOTE_HOST} !^68.241.45.0/20
but it doesn't seem to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
RewriteCond
你只能做正则表达式或字典比较。由于 68.241.45.0/20 的范围是 68.241.32.1–68.241.47.254,因此您可以执行以下操作:With
RewriteCond
you can only do regular expression or lexicographic comparison. And since 68.241.45.0/20 is the range from 68.241.32.1–68.241.47.254, you could do this:RewriteCond 在第二个参数上使用正则表达式。因此,您需要转义点 (.) 并使用正则表达式作为范围。
^68\.241\.[32|47]\.[1|2]?[0-9]+?
RewriteCond uses regular expression on the second parameter. So you need to escape the dots (.) and use regex for the range.
^68\.241\.[32|47]\.[1|2]?[0-9]+?