Give one IP exclusive access to your site

You can usually work on a live website without preventing visitors from accessing it. They might see the odd menu item appear or disappear or an image move etc. but these things are rarely a concern.

However, sometimes you have to restrict access during an update because information might become lost or corrupted or because visitors might become confused. A good example of this is the magento upgrade process where a visitor could end up staring at a blank page for many minutes while the upgrade is taking place.

Unfortunately, you often need to have access while preventing visitors from having access.

Fortunately, this is easily achieved by using the .htaccess file. First, create your alternative page for your visitors (e.g. upgrading_back_soon.php) and put it in the root folder of your site.

Next, add the following to the top of your .htaccess file in the root folder, substituting in your own IP address for A.B.C.D.

RewriteEngine On
RewriteCond %{REMOTE_HOST} !^A\.B\.C\.D
RewriteCond %{REQUEST_URI} !/upgrading_back_soon.php$
RewriteRule .* /upgrading_back_soon.php [R=302,L]

To test from your own IP go through a proxy such as webproxy.ca and confirm that you see your alternative page.

Now you have exclusive access to your site, lets hope you don't need it for too long.


Comments

mehran 5 years, 2 months ago

get ip adress
please give me one or more ip adress of site gamma very thank that you bye.:)

Link | Reply

Paul Whipp 5 years, 2 months ago

IP spoofing is not a big concern here. As you point out, the attacker would need to know the IP addresses that the site is restricted to and they would also need to be on one of those networks in order to have the
potential to see the returned results.

This method is not ultimately secure but its more than adequate to protect staging websites and the like.

Link | Reply

New Comment

required

required (not published)

optional

Australia: 07 3103 2894

International: +61 410 545 357

Feeds

RSS / Atom