How to use .htaccess for keeping visitors out

If you are a Webdesigner, there are many ways and reasons why you might want to keep someone out of your webspace. In my case I was designing a Website and wanted to keep everyone out as long as it wasn’t ready for public. I had the possibility to install a password protection via .htaccess and .htpasswd, but for my taste that was too much work to do. Generating an encoded password was the reason.

So I decided to go another way. For this solution you need to know your IP adress. There are a few ways to do that. The most simple one is to do a google search for ‚what is my ip‘. There you go. Now that you know your IP, half of the work is already done. All you have to do now is to create a .htaccess file (if you haven’t yet) and put it in the desired website directory you want to protect from unwanted visitors.

The content of it should look like this:
Order deny,allow
Deny from all
Allow from

The second line is the most important. It keeps everyone out. The last one should be replaced with your IP, to make sure that you’re the chosen one that may view the contents in this directory from a browser.
Now if you have a Webdesign customer or friend that may view the website aswell, just put in another line allowing another IP adress to access. Like this:

Allow from

Have fun!