Redirect all visitors except from IP number specified

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.  You can find your IP number from sites like
 RewriteEngine on
  RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx  
  RewriteCond %{REQUEST_URI} !/construction.html$ [NC]  
  RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css)$ [NC]  
  RewriteRule .* /construction.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.
  • 254 Users Found This Useful
Was this answer helpful?

Related Articles

301 Redirect from non-www to ww -- Without Looping!

So - you want to improve your search engine rankings, and SEO gurus told you that Google might be...

Add IonCube to a custom php.ini (PHP 5.3+)

IonCube is installed by default on the servers, however if you require adding custom settings...

Block a country using mod_geoip

Do you have a list of countries that you want to block access to your site? Have you tried adding...

Force folder to redirect to https mode

Sometimes webmasters need to force particular folders to load in HTTPS mode. This is ideal for...

Hotlink protecting image.php and GD images

So you've enabled cpanel's hotlink protection, but those bandwidth theives are still attacking...