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

What are the main error types in PHP

How to provide a default model object for relationships?

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

How to generate an array for a dropdown (with ['key' => 'value']) suitable for a dropdown, from a Laravel collection of Eloquent objects?

How to set environmental variables in your .htaccess file

What is camel case?

What is Agile software development?

How to check if a user is logged in, inside a blade file?

What is the loop variable in a @foreach loop in Blade?

301 Redirect a single URL in .htaccess to a new location