Your country & currency

Make yourself at home. Choose your preferred shopping currency.

Your selected country opens its KickHost website. Your shopping currency is saved. Visit country website .

Guide

How to Restrict Access to Directories by IP Address

Restrict access to a directory by IP address with an .htaccess file. Steps for KickHost customers in Kenya.

Share

Limiting your admin area to selected IP addresses is a simple way to keep attackers out. Only visitors from the allowed addresses can open the folder.

To secure your admin area from hackers, you should only allow access to your admin directory from selected IP addresses. You can create a dot htaccess file in the directory where you want to restrict access to specific IP addresses.

For example, if you have a WordPress blog installed on your main directory and you log in via example.com/wp-admin, you should create an htaccess file in /wp-admin/.htaccess and put the following code into it. Please, don’t forget to replace the allowed IP address with your IP address.

order deny, allow
deny from all
allow from YOUR-IP-ADDRESS-HERE

Replace the Your-IP-Address-Here text with your IP address.

You can test this by accessing the wp-admin directory from another IP address, not mentioned in your htaccess file.

Know your IP address first

Check your own address before you add the rule. If your address changes, you may lock yourself out, so use this only if you have a stable connection.

Test and keep a backup

Download a copy of the .htaccess file before editing. After saving, test from an allowed and a blocked connection. If you see a 500 error, restore the copy.

Frequently asked questions

What if my IP changes? Edit the rule and add the new address, or remove the restriction in File Manager.

Is this enough to secure WordPress? It helps, but also use strong passwords, updates and two-factor login.

Related guides

Need cPanel hosting in Kenya? See KickHost hosting plans or contact our team.

Found this useful? Share it.

Need a hand with this?

Our team can help you choose the right domain, hosting or server and set it up properly.

Talk to our team See hosting plans