IP范围.htaccess文件mod_rewite [英] IP range in .htaccess file mod_rewite

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

问题描述

我有这样的,它不工作:

  RewriteEngine叙述上
的RewriteBase / IGRA /
的RewriteCond%{HTTP_USER_AGENT}(SAFA |导航器)[NC]
的RewriteCond%{REMOTE_ADDR}(78 \ 0.30 \ 0.128 \ .0 / 78 \ 0.30 \ 0.159 \ .255)
重写规则^((?!TEMPL /).*)$ TEMPL / $ 1 [L,NC]
 

我相信somwhere下面是问题 - ?地方的IP范围是/在IP范围或者是0/78的一部分

 的RewriteCond%{REMOTE_ADDR}(78 \ 0.30 \ 0.128 \ .0 / 78 \ 0.30 \ 0.159 \ .255)
 

解决方案

您不能在的mod_rewrite 使用的IP地址范围,但您可以使用多个IP开始使用正则表达式或块(管)是这样的:

 的RewriteCond%{REMOTE_ADDR} ^ 78 \ 0.30 \。(128 | 129)\。
 

或者这样:

 的RewriteCond%{REMOTE_ADDR} ^ 78 \ 0.30 \ 0.12 [89] \。
 

I have this and it's not working:

RewriteEngine On
RewriteBase /igra/
RewriteCond %{HTTP_USER_AGENT} (safa|navigator) [NC]
RewriteCond %{REMOTE_ADDR} (78\.30\.128\.0/78\.30\.159\.255)
RewriteRule ^((?!templ/).*)$ templ/$1 [L,NC]

I belive somwhere below is problem - somewhere IP range is it / for IP range or what?0/78 part

RewriteCond %{REMOTE_ADDR} (78\.30\.128\.0/78\.30\.159\.255)

解决方案

You cannot use IP address range in mod_rewrite but you can use multiple IP starting blocks using regex OR (pipe) like this:

RewriteCond %{REMOTE_ADDR} ^78\.30\.(128|129)\.

OR this:

RewriteCond %{REMOTE_ADDR} ^78\.30\.12[89]\.

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

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