When your working on a website on your hosting account or server, it is often a good idea to prevent access to what you are building until you are ready to launch. This is highly recommended when you have a website you don’t want the Global community or worse, your competitors to know about. This little tutorial using .htaccess will show you how to prevent anyone else from checking out your site until you are ready for them. To start with we will need to get your IP address which appears below:
Your IP address is:
Ok, no that you have your IP address, you will need to create a text file called .htaccess that you will be uploading into your ROOT web accessible directory. For Cpanel it will be public_html. There will be no extentions on the file such as .html or .txt, just name it .htaccess. (a little note on files that start with a ‘.’. For apache servers this indicates that the file is hidden, so if you were to upload this file to an accessible root folder, you would see other files in the directory tree but not the .htaccess).
So, now that we have created our .htaccess file we need to enter a few lines of code that will tell the server what we want to do.
Step 1: Deny anyone from reading the .htaccess file:
order deny,allow
deny from all
Step 2: Deny any access other than our own IP address:
deny from all
allow from 38.107.179.220
Step 3: Upload to your ROOT web accessible folder. This would be public_html for Cpanel, or could be www. Check with your host if you are unsure. By uploading to our ROOT folder, this .htaccess will be default for any content you place on your server.
Putting it all together:
order deny,allow
deny from all
In the case of development of a WordPress website or other site that uses .htaccess, download the file from the server, and add the above lines. This works for WordPress, Dolphin, Joomla and Drupal without messing up the website.
When you are ready to make your site public, remove the above lines you added, or if you create an .htaccess on a custom website, that does not have an .htaccess file, just delete it from your server.
Happy development!