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
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 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 find out what version of Laravel you are using?

What is an example of an object literal?

How to review blog posts (written by other users) before they get published on your WordPress blog?

How to use Anonymous classes in PHP 7?

What are generators in PHP, and how do they compare to arrays?

How to block IPv6 IP addresses in .htaccess

How to replace whitespace with a single space

How can you check if a variable is alphanum (alphanumeric, letters and numbers only) in PHP?

How to round a number in JS?

How to get the first row that matches some where queries, or create it if it doesn't exist (in Laravel's Eloquent)?