How to block an IP range based on CIDR in Apache with .htaccess

Apache: How to block an IP range based on CIDR in Apache with .htaccess

If you have a CIDR range that you want to block with .htaccess, use the following format:

  1. Deny from 111.222.111.0/24

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to block an IP range based on CIDR in Apache with .htaccess

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Apache language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to add and remove items to an array in JS?

How to get the last character of a string in JS?

How to set environmental variables in your .htaccess file

How to do comments in Blade files?

An overview of every main PHP array function

How to add the CSRF (Cross-site request forgery) token in Laravel?

How to redirect your website to a new domain/location in .htaccess

What is the difference between reference and primitive data types types in Javascript?

How to select all rows for a certain month (or day, year or time), using Eloquent

How to check if two strings are anagrams in PHP?