假如查出某个 ip 经常对我们的网站进行攻击或者出于其他原因从而打算拒绝该 ip 访问我们的站点的时候,该如何做呢?下面分享一种通过 .htaccess 中拒绝某个 ip 访问的办法。
编辑 .htaccess 文件,输入如下内容:
order allow,deny deny from 110.120.16.11 deny from 108.8.32. allow from all
将以上内容保存后放到站点的根目录下面即可拒绝指定的 ip 访问网站了,以上代码中第二行是拒绝 110.120.16.11 这个 ip 地址访问我们的站点,第三行是拒绝 108.8.32.0 - 108.8.32.255 这个IP段内的用户访问我们的站点。当然如果你想要拒绝所有人访问你的站点?直接使用用 deny from all 就行了。另外禁止的信息中除了可填写IP,还可以用域名来设定,如下:
order allow,deny deny from baidu.com deny from www.google.cn allow from all
您可能感兴趣的文章
- 如何利用.htaccess防盗链网站图片
- 利用.htaccess禁止列表目录
- 通过.htaccess设置网站默认首页
- 如何通过.htaccess修改网站默认首页?
- 10 段实用的 .htaccess 代码片段
- .htaccess如何设置防盗链某个目录的图片
- 使用Apache的htaccess防止图片被盗链
- 使用PHP的GZip压缩功能对网站JS和CSS文件进行压缩加速网站访问速度

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function