Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Redirect all visitors except from IP number specified  (Read 2852 times)

0 Members and 1 Guest are viewing this topic.

Eby Sebastian

  • Newbie
  • *
  • Posts: 14
  • Karma: +1/-0
Redirect all visitors except from IP number specified
« on: October 31, 2013, 02:46:33 pm »

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

It is better to add this if you have a dedicated IP Address. If you are using dynamic IP Address, it will change each time you connect to internet.

 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.
Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!