| Author |  | 
| Qmpeltaty 
 
 
 Joined: 06 Feb 2008
 Posts: 182
 Location: Poland
 
 | 
|  Posted: Thu 06 Aug '15 10:58    Post subject: URL IP block |   |  
| 
 |  
| I need to block the specific url for limited number of IPs. 
 www.domain.com/Console/Servlet?action=login
 
 I can't use Location to block <Location /Console> as other links to Console must be public available. What is the lightest for resources and best way to do this ?
 |  | 
| Back to top |  | 
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Thu 06 Aug '15 14:24    Post subject: |   |  
| 
 |  
| That was very tricky question. It took a while, but I figured it out 
 
  	  | Code: |  	  | <LocationMatch ^/test.php>
 <If "%{QUERY_STRING} =~ /action=login/">
 Require ip 192.168.178.100
 </If>
 </LocationMatch>
 
 | 
 |  | 
| Back to top |  | 
| Qmpeltaty 
 
 
 Joined: 06 Feb 2008
 Posts: 182
 Location: Poland
 
 | 
|  Posted: Fri 07 Aug '15 9:18    Post subject: |   |  
| 
 |  
| Great. What you think about this ? 
 <LocationMatch "^/Console/Servlet.*$">
 Require ip ..
 </LocationMatch>
 
 
 Another question - QUERY_STRING - is it the part of the URL after "?" , so according to my URL which part would be the QUERY_STRING ?
 
 this www.domain.com/Console/Servlet?action=login or
 www.domain.com/Console/Servlet?action=login
 |  | 
| Back to top |  | 
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Fri 07 Aug '15 10:23    Post subject: |   |  
| 
 |  
| With LocationMatch I didn't get it working. 
 
  	  | Quote: |  	  | Another question - QUERY_STRING - is it the part of the URL after "?" , so according to my URL which part would be the QUERY_STRING ? | 
 
 The QUERY_STRING is the part after the called url.
 The questionmark is the separator of the url and the query string.
 Each part of the query string is separated by a ampersand ( & ).
 Each query string part must have a key and optional can have a value ( key=value ).
 |  | 
| Back to top |  | 
| Qmpeltaty 
 
 
 Joined: 06 Feb 2008
 Posts: 182
 Location: Poland
 
 | 
|  Posted: Fri 07 Aug '15 13:22    Post subject: |   |  
| 
 |  
| So in my case 
 URL = www.domain.com/Console/
 QUERY_STRING = Servlet?action=login
 |  | 
| Back to top |  | 
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Fri 07 Aug '15 15:41    Post subject: |   |  
| 
 |  
| in your case only action=login |  | 
| Back to top |  |