How to Restrict/Block IP Address using .htaccess File?
Hi,
Today, I would like to show you how to block ip address htaccess. it's simple example of how to restrict ip address in .htaccess. it's simple example of restrict ip address htaccess. you can see htaccess deny ip address.
If you need to restrict some ip address for your website then i will help you how to block ip address using htaccess file. i will give you simple example of block ip address in .htaccess.
let's see code of allow and deny ip address in .htaccess file:
Deny IP Address in .htaccess
Example 1: Block One IP Address:
simply create .htaccess file in your root directory and add following code on it.
.htaccess
deny from 111.111.111.111
Example 2: Block Multiple IP Addresses:
simply create .htaccess file in your root directory and add following code on it.
.htaccess
deny from 111.111.111.111 111.111.111.112 111.111.111.113
you will see layout as like bellow:
Allow IP Address in .htaccess
Example 1: Allow One IP Address:
simply create .htaccess file in your root directory and add following code on it.
.htaccess
order deny,allow
deny from all
allow from 111.111.111.111
Example 2: Allow Multiple IP Addresses:
simply create .htaccess file in your root directory and add following code on it.
.htaccess
order deny,allow
deny from all
allow from 111.111.111.111 111.111.111.112 111.111.111.113
i hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Generate and Add SSH Key in Gitlab?
- How to Generate SSH Key in Ubuntu Server?
- How to Check Apache Access & Error Log Files in Ubuntu Server?
- How to Whitelist/Allow IP Address in Apache Ubuntu?
- How to Restrict/Block IP Address in Apache Ubuntu?
- How to Set Up Password Authentication with Apache in Ubuntu?
- How to Install Composer in Ubuntu Server?
- How to Install Apache PHP MySQL and Phpmyadmin on Ubuntu?
- How to Install Apache Web Server on Ubuntu Server?
- Codeigniter Remove index.php form URL using htaccess