Blocking Visitors #
Posted 04th October, 2018
You may want to block all visitors apart from yourself, or block one individual visitor. This guide will cover three ways of doing this, in order of simplicity.
- A .htaccess file
- Enabling Cloudflare and using their blocking tools.
- Geolocation and application blocking
The .htaccess file #
A .htaccess file gives the server directives on how to handle visitors to your website. This can include rewrites, php directives, caching rules, and access rights.
All .htaccess files are recursive, so they apply to all folders beneath them in the website structure.
Lockdown Access #
You can then add the allow to your .htaccess file as follows:
Order Deny,Allow Deny from all Allow from 22.214.171.124 Allow from 126.96.36.199
188.8.131.52 with as many IP addresses you would like to allow to access your website.
Block Visitor #
To block an individual visitor you will need to find out their IP addresses. You can then add the block to your .htaccess file as follows:
Order Deny,Allow Deny from 184.108.40.206
220.127.116.11 with the IP in question. You can add multiple lines.
Cloudflare and Caching #
Cloudflare is a global CDN (Content Delivery Network) which sits in front of your website. This has various benefits, but one is that it allows use as a gateway.
You can use the
Threat Control options to make it more difficult for visitors from a specific country to visit you by presenting them with a CAPTCHA verification field before they can visit your website.
Geolocation and Application Blocking #
The most complicated, but most flexible, way to block visitors is to geolocate their location based on their IP address. This technique is often used to provide a website in a set currency or language based on the user.