จะทำการ block IP โดยใช้ .htaccess ได้อย่างไร

สามารถทำได้โดยระบุ IP ที่ต้องการบลอกที่ .htaccess ไฟล์
โดเยการสร้างไฟล์วางไว้ที่ public_html แล้วเพิ่มบันทัดต่อไปนี้ในไฟล์

order allow,deny
deny from xxx.xxx.xxx.xxx   <<<ใส ip ที่ต้องการบลอก
allow from all

โดยจะบลอกทุก user ที่ใช้ 127.0.0.1 IP

สามารถดาวน์โหลด IP ของแต่ละประเทศได้ที่ 
https://www.countryipblocks.net/country_selection.php

 

ตัวอย่าง อนุญาติ เฉพาะipไทย บล็อก ipนอกทั้งหมด

 

ตัวอย่าง บล็อก เฉพาะip บางประเทศ เช่นบล็อกip CANADA อนุญาติ ipอื่นทั้งหมด

  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

วิธีเขียนโค้ด php ใน ไฟล์นามสกุล html

อยากเขียนโค้ด php ใน ไฟล์นามสกุล html ทำได้โดย .htaccess ความรู้เก่า   <IfModule...

การทำ Redirect from HTTPS เป็น HTTP

There are some specific cases when you want to redirect particular URL or a single website to be...

วิธีการเปลี่ยนหน้าแรกจากไฟล์ index เป็นชื่ออื่นที่ต้องการใน hosting ของเรา

ภายในไฟล์ .htacess ให้ระบุข้อมูลต่อไปนี้ครับ DirectoryIndex ชื่อไฟล1 ชื่อไฟล์2 ชื่อไฟล์3...

Leverage browser caching

Change the request headers of your resources to use caching. Optimize your caching strategy....

How to enable displaying php errors on site

To enable displaying PHP errors Open your website with file manager61 Go...