How to block an IP address in .htaccess

Apache: How to block an IP address in .htaccess

If you have a specific IP address that you want to block access to, you can do this in Apache's .htaccess with the following code

  1. Deny from x.x.x.x

(replace x.x.x.x with the actual IP address)

webdevetc profile pic

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


Comments and discussion about How to block an IP address in .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 check if a object has a static variable defined?

How to Extract Query String (from a URL) Into an Associative Array in PHP

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

How to merge/concat two arrays together in JS?

How to change the order that migrations happen?

How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

How to block an IP address in .htaccess

How to eager load multiple levels of relationships in Eloquent?

How to remove .php from the end of URLs with .htaccess

How to access the Laravel's route parameters outside of the controller?