WordPress: Restricting website access to your IP address

For various reasons, you might need to restrict your website to your IP address.
This is particularly useful for development purposes, as it blocks access to the website (or to redirect the visitor somewhere else), while allowing the developer to navigate through it normally.

In order to only allow your IP address to access your website (or blog) and block everyone else from accessing it, just add these 3 lines to your .htaccess file:

order deny,allow
allow from xx.xxx.xxx.xx
deny from all

Simply replace “xx.xxx.xxx.xx” with your own IP address, save your .htaccess file and test it out!
If you can’t find your IP address, simply use WhatIsMyIp.com or any similar site to obtain it (there are plenty of them).

A very efficient way to test if someone is able to access your website through a different IP address is by using a web proxy to access it (such as MegaProxy for example).
To revert the changes and therefore allow everyone to access the website again, simply delete those lines from .htaccess and save the file again.

Leave a Reply