IP range in .htaccess mod_rewite file

I have this and it does not work:

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 believe that somewhere below the problem is somewhere the IP range is / for the IP range or what? 0/78 part

 RewriteCond %{REMOTE_ADDR} (78\.30\.128\.0/78\.30\.159\.255) 
+1
source share
2 answers

You cannot use the IP range in mod_rewrite , but you can use multiple IP start blocks using the regular expression OR (pipe), like this:

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

Or that:

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

I do not think that it is possible to specify an IP range.

However, a range could be emulated using CIDR notation. (note that / is actually used in CIDR notation).

So, in your case, since it looks like a continuous block of IP addresses .. try:

 RewriteCond %{REMOTE_ADDR} 78\.30\.128\.0/24 
0
source

Source: https://habr.com/ru/post/1316542/


All Articles