How Can We Help?

Whitelisting VPN IPs

How to restrict access to your website’s admin area using .htaccess

Introduction
For website administrators, securing the back end or administration area of your website is crucial to prevent unauthorised access and potential security breaches. One effective method to enhance this security is by using an .htaccess file. This guide will walk you through the steps to restrict access to your website’s backend using your VPNUK Dedicated IP and .htaccess.

Prerequisites
Access to your website’s root directory via FTP or a File Manager.
A text editor to edit the .htaccess file.

Step-by-Step Guide
1. Navigate to root or to the directory you would like to restrict access to.
2. Locate or Create a .htaccess file.
3. Edit the .htaccess file to restrict access.
4. Save and upload the .htaccess file.

Restrict by VPNUK IP Address:

To allow only your VPNUK Dedicated IP addresses to access your back end, add the following lines, replacing admin_directory/ with your actual admin directory and 1.2.3.4 with your unique VPNUK Dedicated IP address:

# Start IP whitelisting rule

# Enable mod_rewrite
RewriteEngine On

# Allow access only from the specified VPNUK IP address
# Replace 1.2.3.4 with your VPNUK unique IP
RewriteCond %{REMOTE_ADDR} !=1.2.3.4
# Replace admin_directory with your admin folder name
RewriteRule ^admin_directory/ - [F]

# End IP whitelisting rule



Repeat the ‘RewriteCond %{REMOTE_ADDR} !=1.2.3.4’ line for each Dedicated IP address you wish to grant access.