From time to time it’s necessary to block access to people from various parts of the website.

Many people use the following method when developing a site and don’t want others to see it. You only need to replace the “xxx” with your actual IP number.

Note – You can find your IP number from sites like http://www.whatismyip.com 

 
 RewriteEngine on
 RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx
 RewriteCond %{REQUEST_URI} !/underConstruction.html$ [NC]
 RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css)$ [NC]
 RewriteRule .* /underConstruction.html [R=302,L]
 
This can also be useful to block areas of your site such as an /admin or /wp-admin section to prevent any outside intrusion attempts.

in HTACCESS