Reputation: 119
What Is wrong with this format ?
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^5. [OR]
RewriteCond %{REMOTE_ADDR} ^23.27. [OR]
RewriteCond %{REMOTE_ADDR} ^221.232.
RewriteRule ^(.*)$ http://www.website/junk/ [R]
the idea as you can imagine, is to redirect users whos ip starts with 5. or 23.27.
or 221.232. to the website/junk/ folder, and i would need to add more ranges to this.
the problem im having with the above is that it also redirects my own ip which starts with like 24.
telling me something is wrong with the format and probably not catching just the first set of numbers
yes i realize I am after ranges,and not single ip addresses, but its how i want it.
thanks
Upvotes: 2
Views: 223
Reputation: 785481
DOT is a special character in regex that needs to be escaped otherwise it matches any character
So ^5.
may also match 5.3.2.1
OR 50.40.30.20
Use this code:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^5\. [OR]
RewriteCond %{REMOTE_ADDR} ^23\.27\. [OR]
RewriteCond %{REMOTE_ADDR} ^221\.23\.
RewriteRule ^ http://www.website/junk/ [L,R]
Upvotes: 2