Fixed Knowledge Base

Get all the help you need here.

Blocking Visitors

Posted 04th Oktober, 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 need to find out the IP Address of anyone who should be allowed to access the website. You can find this out by visiting IP.me.uk.

You can then add the allow to your .htaccess file as follows:

Order Deny,Allow
Deny from all
Allow from 1.1.1.1
Allow from 1.2.3.4

Replace 1.1.1.1 and 1.2.3.4 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 1.1.1.1

Replace 1.1.1.1 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.