Redirect all visitors except from IP number specified Print

  • 254

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 http://www.whatismyip.com
 
 
 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.

Was this answer helpful?

« Back

Powered by WHMCompleteSolution